Real Java Interview Questions

J

Jobs

Looking for answers visit www.questpond.com

JAVA Interview questions

OOPS and CORE JAVA

What is JVM (Java Virtual Machine)?
What is JIT (Just-in-Time) Compilation?
What is Object Oriented Programming?
What's a Class?
What's an Object?
What's the relation between Classes and Objects?
What are different properties provided by Object-oriented systems?
How do you implement inheritance in Java?
How can we implement polymorphism in Java?
What's an interface and how will you go about implementing an
interface?
What is an Abstract class?
What are Abstract methods?
What's the difference between "Abstract" classes and "Interfaces"?
What's difference between Static and Non-Static fields of a class?
What are inner classes and what's the practical implementation of
inner classes?
What are packages?
What is a constructor in class?
Can constructors be parameterized?
Can you explain transient and volatile modifiers?
What is the use if "instanceof " keyword?
What are Native methods in Java?
Explain in depth Garbage collector?
How does the garbage collector determine that the object has to be
marked for deletion?
Can you explain "finalize()" method?
How can we force the garbage collector to run?
What's the main difference between "Switch" and "If " comparison?
What's the use of JAVAP tool?
What are applets?
In which package is the applet class located?
What are native interfaces in Java?
what are Class loader's?
what is Bootstrap, Extension and System Class loader?
Can you explain the flow between bootstrap, extension and system class
loader?
Can you explain how can you practically do dynamic loading?
How can you copy one array in to a different array?
Can you explain the core collection interfaces?
Can you explain in brief the collection classes which implement the
collection interfaces?
What's the difference between standard JAVA array and ArrayList class?
What's the use of "ensureCapacity" in ArrayList class?
How can we obtain an array from an ArrayList class?
What is "LinkedList" class for?
Can you explain HashSet class in collections?
what is LinkedHashSet class?
what is a TreeSet class?
what's the use of Comparator Interface?
How can we access elements of a collection?
What is Map and SortedMap Interface?
Have you used any collection algorithm?
Why do we use collections when we had traditional ways for collection?
Can you name the legacy classes and interface for collections?
What is Enumeration Interface?
what's the main difference between ArrayList / HashMap and Vector /
Hashtable?
Are String object Immutable, Can you explain the concept?
what is a StringBuffer class and how does it differs from String
class?
what is the difference between StringBuilder and StringBuffer class?
What is Pass by Value and Pass by reference? How does JAVA handle the
same?
What are access modifiers?
what is Assertion?
Can you explain the fundamentals of deep and shallow Cloning?
How do we implement Shallow cloning?
How do we implement deep cloning?
What's the impact of private constructor?
What are the situations you will need a constructor to be private?
Can you explain final modifier?
What are static Initializers?
If we have multiple static initializer blocks how is the sequence
handled?
Define casting? What are the different types of Casting?
Can you explain Widening conversion and Narrowing conversion?
Can we assign parent object to child objects?
Define exceptions?
Can you explain in short how JAVA exception handling works?
Can you explain different exception types?
Can you explain checked and unchecked exceptions?
Can we create our own exception class?
What are chained exceptions?
What is serialization?
How do we implement serialization actually?
What's the use of Externalizable Interface?

Threading

What's difference between thread and process?
What is thread safety and synchronization?
What is semaphore?
What are monitors?
What's the importance of synchronized blocks?
How do we create threads?
what's the difference in using runnable and extends in threads?
Can you explain Thread.sleep?
How to stop a thread?
What is wait() and notify() ?
Can you explain how Scheduling and Priority works in threads?
Can you explain Yielding in threading?
what are daemon threads?

JDBC

How does JAVA interact with databases?
Can we interact with non-relational sources using JDBC?
Can you explain in depth the different sections in JDBC?
Can you explain in short how you go about using JDBC API in code?
How do you handle SQL exceptions?
If there is more than one exception in SQLException" class how to go
about displaying it?
Explain Type1, Type2, Type3 and Type4 drivers in JDBC?
What are the advantages and disadvantages of using JDBC-ODBC bridge
driver?
What are the advantages and disadvantages of using Native-API/
Partially Java Driver?
What are the advantages and disadvantages of using Net-Protocol/ All-
Java driver?
What are the advantages and disadvantages of using Native-protocol/
All-Java driver?
Define meta-data?
What is DatabaseMetaData?
Can you explain "ConnectionFactory" class?
I want to display tables of a database how do I do it?
Define "ResultSetMetaData"?
What is the difference between "ResultSet" and "RowSet"?
Can "ResultSet" objects be serialized?
Can you explain "ResultSet", "RowSet", "CachedRowset", "JdbcRowset"
and "WebRowSet" relation ship?
what are the different types of resultset?
Explain the concept of "PreparedStatement "statement interface?
What's the difference between "Statement" and "PreparedStatement"?
How can we call stored procedure using JDBC?
Can you explain "CallableStatement" interface in detail?
How do you get a resultset object from stored procedure?
How can we do batch updates using "CallableStatement" Interface?
Define transactions?
what is ACID in transaction?
what are the four essential properties of a transaction?
Explain concurrency and locking?
What are different types of locks?
What are the different types of levels of resource on which locks can
be placed?
Define lock escalation?
What is Table level and Row level locking?
What are the problems that can occur if you do not implement locking
properly?
What are different transaction levels?
Twist: - what are different types of locks?
What is difference between optimistic and pessimistic locking?
What are deadlocks?
How can we set transaction level through JDBC API?
Can you explain transaction control in JDBC?
What are Savepoints in a transaction?
Servlets and JSP
What are Servlets?
What are advantages of servlets over CGI?
Can you explain Servlet life cycle?
What are the two important API's in for Servlets?
Can you explain in detail "javax.servlet" package?
What's the use of ServletContext?
How do we define an application level scope for servlet?
What's the difference between GenericServlet and HttpServlet?
Can you explain in detail javax.servlet.http package?
What's the architecture of a Servlet package?
Why is HTTP protocol called as a stateless protocol?
What are the different ways we can maintain state between requests?
What is URL rewriting?
What are cookies?
What are sessions in Servlets?
What's the difference between getSession(true) and getSession(false) ?
What's the difference between "doPost" and "doGet" methods?
Which are the different ways you can communicate between servlets?
What is functionality of "RequestDispatcher" object?
How do we share data using "getServletContext ()"?
Explain the concept of SSI?
What are filters in JAVA?
Can you explain in short how do you go about implementing filters
using Apache Tomcat?
Twist: - Explain step by step of how to implement filters?
what's the difference between Authentication and authorization?
Explain in brief the directory structure of a web application?
Can you explain JSP page life cycle?
What is EL?
how does EL search for an attribute?
What are the implicit EL objects in JSP?
How can we disable EL?
what is JSTL?
Can you explain in short what the different types of JSTL tags are?
How can we use beans in JSP?
What is <jsp:forward> tag for ?
What are JSP directives?
what are Page directives?
what are include directives?
Can you explain taglib directives?
How does JSP engines instantiate tag handler classes instances?
what's the difference between JavaBeans and taglib directives?
what are the different scopes an object can have in a JSP page?
what are different implicit objects of JSP?
what are different Authentication Options available in servlets?
Can you explain how do we practically implement security on a
resource?
How do we practically implement form based authentication?
How do we authenticate using JDBC?
Can you explain JDBCRealm?
Can you explain how do you configure JNDIRealm?
How did you implement caching in JSP?

EJB

What is EJB?
what are the different kind of EJB's?
you are designing architecture for a project how do you decide whether
you should use session, entity or message driven bean?
Can you explain "EJBHome" and "EJBObject" in EJB?
Can client directly create object of session or entity beans?
Can you explain the concept of local interfaces?
What are the limitations of using Local object?
Which application server have you used for EJB ?
Can you explain step by step practically developing and deploying EJB
component?
what is Passivation and Activation in EJB?
Can beans who are involved in transaction have "Passivation" process?
How does the server decide which beans to passivate and activate?
In what format is the conversational data written to the disk?
Can you explain in brief Life cycle for Stateless and Stateful beans?

Struts

What's MVC pattern?
Define struts?
Can you explain the directory structure for a struts folder in brief ?
Can you give an overview of how a struts application flows?
Twist: - What are action and action form classes in Struts?

XML and WebServices

What is XML?
What is the version information in XML?
What is ROOT element in XML?
If XML does not have closing tag will it work?
Is XML case sensitive?
What is the difference between XML and HTML?
Is XML meant to replace HTML?
Can you explain why your project needed XML?
What is DTD (Document Type definition)?
What is well formed XML?
What is a valid XML?
What is CDATA section in XML?
What is CSS?
What is XSL?
What is element and attributes in XML?
What are the standard ways of parsing XML document?
In What scenarios will you use a DOM parser and SAX parser?
What is XSLT?
Define XPATH?
What is the concept of XPOINTER?
What is a Web Service ?
What is DISCO ?
What is SOAP ?
What is WSDL ?
Can you explain UDDI ?
Can you explain JAXP ?
What is a XML registry?
What is JAXR?
What is JAXM?
Can you explain how JAXM messaging model works?
Can you explain JAX-RPC?
Internationalization
Can you explain i18n and l10n?
Can you explain internationalization and localization?
What is Locale?
How do we display numbers, currency and Dates according to proper
Locale format?
what are resource bundles?
How do we load a resource bundle file?
How can we do inheritance in resource bundles?

JNI

What is Native Interface in JAVA?
Can you say in brief steps required to implement Native interfaces in
Java?
Can JNI be used for VB6, C# or VB.NET directly?
What are JNI functions and pointers?
How does the garbage collector know JNI objects are no more used?
Twist: - What are the different types of references JNI supports?
Twist: - How to do you delete global objects?
how does the native language C or C++ understand data types in JAVA?
Can you explain exception handling in JNI?
What are limitations for "JNIEnv" pointer in multi-threading
scenarios?
What are the advantages and disadvantages of using "JNI"?

Architecture

What are design patterns ?
What is the difference between Factory and Abstract Factory Patterns?
What is MVC pattern?
Twist: - How can you implement MVC pattern in Servlets and JSP?
How can we implement singleton pattern in JAVA?
How do you implement prototype pattern in JAVA?
Twist: - How to implement cloning in JAVA? What is shallow copy and
deep copy ?
Can you give a practical implementation of FAÇADE patterns?
How can we implement observer pattern in JAVA?
What is three tier architecture?
What is Service Oriented architecture?
What is aspect oriented programming?

Project Management

What is project management?
Is spending in IT projects constant through out the project?
Who is a stakeholder ?
Can you explain project life cycle ?
Twist :- How many phases are there in software project ?
Are risk constant through out the project ?
Can you explain different software development life cycles ?
What is triple constraint triangle in project management ?
What is a project baselines ?
What is effort variance?
How is normally a project management plan document organized ?
How do you estimate a project?
What is CAR (Causal Analysis and Resolution)?
What is DAR (Decision Analysis and Resolution) ?
What is a fish bone diagram ?
Twist:- What is Ishikawa diagram ?
What is pareto principle ?
Twist :- What is 80/20 principle ?
How do you handle change request?
What is internal change request?
What is difference between SITP and UTP in testing ?
What is the software you have used for project management?
What are the metrics followed in project management?
Twist: - What metrics will you look at in order to see the project is
moving successfully?
You have people in your team who do not meet there deadlines or do not
perform what are the actions you will take ?
Twist :- Two of your resources have conflicts between them how would
you sort it out ?
What is black box testing and White box testing?
What's the difference between Unit testing, Assembly testing and
Regression testing?
What is V model in testing?
How do you start a project?
How did you do resource allocations?
How will you do code reviews ?
What is CMMI?
What are the five levels in CMMI?
What is continuous and staged representation?
Can you explain the process areas?
What is SIX sigma?
What is DMAIC and DMADV ?
What are the various roles in Six Sigma implementation?
What are function points?
Twist: - Define Elementary process in FPA?
What are the different types of elementary process in FPA?
What are the different elements in Functions points?
Can you explain in GSC and VAF in function points?
What are unadjusted function points and how is it calculated?
Can you explain steps in function points?
What is the FP per day in your current company?
Twist :- What is your company's productivity factor ?
Do you know Use Case points?
What is COCOMO I, COCOMOII and COCOMOIII?
What is SMC approach of estimation?
How do you estimate maintenance project and change requests?

UML

What is UML?
How many types of diagrams are there in UML ?
Twist :- Explain in short all types of diagrams in UML ?
What are advantages of using UML?
Twist: - What is Modeling and why UML ?
What is the sequence of UML diagrams in project?
Twist: - How did you implement UML in your project?
Just a small Twist: - Do I need all UML diagrams in a project?
Give a small brief explanation of all Elements in activity diagrams?
Explain Different elements of a collaboration diagram ?
Explain Component diagrams ?
Explain all parts of a deployment diagram?
Describe the various components in sequence diagrams?
What are the element in State Chart diagrams ?
Describe different elements in Static Chart diagrams ?
Explain the different elements of a Use Case ?
Twist: - What is the difference between Activity and sequence diagrams?
(I leave this to the readers)
 
R

Roedy Green

JAVA Interview questions

Where may a see a large sample of your code?

Where can a view an example of your applications running on the web?

May I see a sample of your program documentation?

Here is a small problem to solve. Please come back tomorrow with as
much as you can complete. Don't forget the overall programmer
documentation, the Javadoc and the user documentation.

What are the names of some members of programmer teams you have worked
on?
 
R

Roedy Green

What's a Class?
What's an Object?

Don't be silly. Good programmers could use these without being able
to articulate the formal definition, and any twit can memorise the
text book definition and still not be able to code the Goldilocks
problem.
 
P

Patricia Shanahan

Roedy said:
Where may a see a large sample of your code?

Where can a view an example of your applications running on the web?

May I see a sample of your program documentation?

Now that I'm a student the last three questions are not so tough. For
many years, all my Java programs were either trivial exercises or
confidential. I could not have shown a prospective employer anything
worthwhile.

How do people who use those questions handle that situation?

Patricia
 
E

Esmond Pitt

Jobs said:
What is JIT (Just-in-Time) Compilation?

A JVM technology that was obsoleted in May 2000.
How do you implement inheritance in Java?

You don't. Java does.
How can we implement polymorphism in Java?
Ditto.

What are Native methods in Java?

Methods that are not in Java.
How can we force the garbage collector to run?

You can't.
What's the main difference between "Switch" and "If " comparison?

One is an apple, the other is an orange.
What's the use of JAVAP tool?

Very little. I use it about four times a year. Used it this morning
oddly enough.
In which package is the applet class located?

There is no such class.
What are native interfaces in Java?

There is no such thing.
How can you copy one array in to a different array?

I don't ever do that.
What's the use of "ensureCapacity" in ArrayList class?

None that the programmer needs to be aware of.
Have you used any collection algorithm?

I put the bins out every Wednesday night.
What is Pass by Value and Pass by reference? How does JAVA handle the
same?

It doesn't. It only handles PBV. It also handles pass by remote
reference but you didn't ask about that.
Can we assign parent object to child objects?

First please define these terms, and fix your grammar while you're about it.
What are monitors?

A language structure invented by Per Brinch Hansen that sadly doesn't
exist in Java.
Can you explain how Scheduling and Priority works in threads?

No. How scheduling works in Java is undefined.
If there is more than one exception in SQLException" class how to go
about displaying it?

Your question is meaningless.
Explain Type1, Type2, Type3 and Type4 drivers in JDBC?

Your question is barely relevant to anybody.
what is ACID in transaction?

An acronym for the four essential properties of a transaction.
what are the four essential properties of a transaction?

The things that ACID stands for.
What are the two important API's in for Servlets?

The TWO important APIs?
Why is HTTP protocol called as a stateless protocol?

Because it is.
Who is a stakeholder ?

A misapplication of a term from gambling where a stakeholder is an
independent party who holds the bets.
Twist :- How many phases are there in software project ?

Which specific software project are you talking about?
 
T

Travis James

Patricia said:
Now that I'm a student the last three questions are not so tough. For
many years, all my Java programs were either trivial exercises or
confidential. I could not have shown a prospective employer anything
worthwhile.

How do people who use those questions handle that situation?

Patricia

Personally, I cannot say that I've ever done an interview with the
aforementioned questions. I would have to know them ahead of time and
even then might not be able to answer due to all work being internal
company property.

In a recent phone interview with Google, I was asked to fire up Google
Docs and walk through a problem real-time with the interviewer.

While the post was blatant spam, I at least found the list to be a
useful set of ponderables.
 
S

Sabine Dinis Blochberger

Travis said:
Personally, I cannot say that I've ever done an interview with the
aforementioned questions. I would have to know them ahead of time and
even then might not be able to answer due to all work being internal
company property.

Agreed. I was asked to show some source code in an interview and I was a
little taken aback - it's either my intellektual property (which I don't
want to give away like that) or a former employers.
In a recent phone interview with Google, I was asked to fire up Google
Docs and walk through a problem real-time with the interviewer.

While the post was blatant spam, I at least found the list to be a
useful set of ponderables.

Ok, but does it really help an empoyer asking these things? Someone
fresh out of a course can answer these textbook like question easy, or
do like Roedy and be a smart alec ;)

It seems companies ask all these high-standard questions and the reality
is that their development department is a mess as anyone elses :p
 
C

Chris Dollin

Bent said:
while (true)
{
new Object();
}

A smartarse compiler [or JIT] might eliminate the `new`, since the
object isn't used and its constructor doesn't do anything significant;
so this doesn't /force/ the GC to run. Yes?
 
A

Andrew Thompson

Sabine said:
[quoted text clipped - 21 lines]
even then might not be able to answer due to all work being internal
company property.

Agreed. I was asked to show some source code in an interview and I was a
little taken aback - it's either my intellektual property (which I don't
want to give away like that) or a former employers.

Most interviewers are idiots.

OTOH, sometimes you encounter an interviewer who is
a little more savvy.

This interviewer might almost be expecting an answer to
the effect. "Sorry, that is confidential" which *assures the
employer/interviewer that you are not about to 'spill the
beans' on the trade secrets of *this* employer, to the
very next!*

OTOH, they might prefer to hear.
"Sorry, cannot tell you about the last *commercial/confidential*
project I was involved with, but I have also had involvement with
Open Source projects ...."


* I supect that a lot of these interview questions that programmers
identify as nonsense, come down to a 'test of character/ethics'.
 
A

Andrew Thompson

Andrew Thompson wrote:
...
* I supect that a lot of these interview questions that programmers
identify as nonsense, come down to a 'test of character ...

Particularly questions that seem 'unsolvable'.

My answer would be 'bump it up the line to the boss'.

The important thing being to recognise that need, and act
appropriately, rather than suffering a nervous breakdown,
and collapsing on the ground with associated twitching
and salivating.

They want to check you know how to 'cede responsiblilty'
for seemingly unsolvable problems, and take the most
appropriate action of bumping it 'one step up the line
of command' - don't want no 'loan eagles' here.

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200711/1
 
A

Andrew Thompson

Bent said:
while (true)
{
new Object();
}

If you really have enough time to check each of those* answers
for correctness**, perhaps you might be willing to trawl trhough
the JavaDoc comments of an open source project of mine,
looking for spelling/grammatical errors.

What'a'ya' say?

* (Mostly) sarcastic replies to a spammer.

** Which I regard as a completely *inefficient* use of your
many talents.

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200711/1
 
L

Lew

Travis James wrote, quoted or indirectly quoted
Andrew said:
This interviewer might almost be expecting an answer to
the effect. "Sorry, that is confidential" which *assures the
employer/interviewer that you are not about to 'spill the
beans' on the trade secrets of *this* employer, to the
very next!*

OTOH, they might prefer to hear.
"Sorry, cannot tell you about the last *commercial/confidential*
project I was involved with, but I have also had involvement with
Open Source projects ...."

Andrew has the best interview skills here.

If all you have written is code for work, you probably aren't the best
candidate for the job. The best programmers don't put down their keyboards
when they go home.

The favored candidate will say, "I have samples up on sourceforge - I wrote
the Blazky module for the Frogovia project."

Or at least be able to point to some code out in the public, preferably with
an article or series of articles or blogs that establish them as a presence in
the development noosphere.

If two candidates of seemingly similar skill present themselves, the boss will
probably be more impressed with the one who has been publishing programs and
articles, and who keeps studying and perfecting their craft during "off"
hourse, over one who closes up shop at 5:17 PM.

"Can we see some work you've done?" is a perfectly reasonable question, and
the best candidates will have a rich portfolio for the client to review.
OTOH, sometimes you encounter an interviewer who is
a little more savvy.

The savvy ones ask open-ended questions designed to get you to reveal
yourself, not merely to check off a buzzword on their list.
 
D

Daniel Pitts

Bent said:
while (true)
{
new Object();
}

Cheers,
Bent D
That might not force a GC run. It could lead to a OOME or the optimizer
might remove the creation altogether.
 
B

Bent C Dalager

Bent said:
while (true)
{
new Object();
}

A smartarse compiler [or JIT] might eliminate the `new`, since the
object isn't used and its constructor doesn't do anything significant;
so this doesn't /force/ the GC to run. Yes?

Very well then:

while (true)
{
System.out.println(new Object());
}

While a compiler /might/, theoretically, "know" what that code does
and so do away with the new object and just output the text that would
have been produced by each, that would be asking a bit too much of it
methinks :)

Cheers,
Bent D
 
H

Hunter Gratzner

Ok, but does it really help an empoyer asking these things?

The OP's questions are originating and targeting another culture. It
is about Indian outsourcing companies trying to get programmers.
Desperately.

The companies, their HR types, don't know what it takes to be a good
programmer or what this Java thing is, so they use question catalogs.
They either rip them off somewhere or buy them (often also ripped off
material).

The applicants want to get a high-paid job, whatever it takes. So they
obtain interview questions, too. And they memorize the answers. It is
not about knowledge, it is about appearence. And therefore they fake
things like there is no tomorrow. E.g. blogs are set up with stolen
contents to appear knowledgeable (hello Umesh/Ohmesh ...).

Dealing in interview questions has become a profitable business.
Companies are selling to both sides.
 
P

Patricia Shanahan

Daniel said:
That might not force a GC run. It could lead to a OOME or the optimizer
might remove the creation altogether.

The optimizer problem can be dealt with by doing something with the
Object, such as add up the hash codes, and print a line whenever the sum
is zero.

The documentation for OutOfMemoryError says "Thrown when the Java
Virtual Machine cannot allocate an object because it is out of memory,
and no more memory could be made available by the garbage collector."

Arguably, a component in the JVM which predicts whether there is
collectible garbage should be considered part of the garbage collector,
so GC has run before the OOME.

Patricia
 
L

Lew

Greg said:
Usually the best candidate has poor interview skills, bad candidates
have lots of practice.

Funny, but not 100% true.

Consultants and contractors have a lot of practice. People who've been real
useful would, too, because good "interview skills" means to be personable,
knowledgeable and committed to the well-being of your client.

The most skilled interviewee is the one who simply is good for the job, is
well aware of that, and showed up in order to provide benefit for the
prospective employer. An interview can transcend the question-and-answer
format of some high-school pop quiz and be a meaningful conversation about a
company's goals and purpose.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top