Java Interview Questions

aaf5856df69049c5bb6800ad29d5da8d
0

Java Queries:

  • What is your understanding with serialization? Where you have use that?
  • What is a difference between Abstract class and interface? Give example where you will you.
  • Abstract class and where you will use interface.
  • What is a difference between HashMap and Properties Class.
  • Where instance variable are stored and where local variable are stored.
  • Have you ever overridden equal method?
  • What new features added to JDK 1.5? Explain few out of those?
  • Which driver type you have use in JDBC connection and Why?
  • What is the difference between Check and Uncheck exception? How exceptions are handled in your project.
  • What is difference between Applet and servlet?
  • What will be returned from this block.

try{
.
.
.
return 3;

}catch(Exception e){
.
.
.
return -1;

}finally{
.
.
.
return 0;
}

 

  • Difference between Set & Arraylist.
  • Is Set a class or an interface?
  • Can a private class be executed? How do we access public method of private class?
  • If public static void main(String args[]) is changed to protected static void main(String args[]), will the class compile? Will the class be executed using java command?
  • If public static void main(String args[]) is changed to public static void main(String name[]), will the class compile? Can the class be executed using java command?
  • Is finally block manadatory in try/catch block?
  • Can runtimeexception be extended?
  • While overriding methods, what are rules applicable for Exception?
  • While overriding methods, what are rules applicable for access modifiers?
  • Can a class have a private constructors?
  • What isi serialization?
  • What is the difference between abstraction and encapsulation?
  • What is the difference between abstract class and interface?
  • What are the access specifiers and why interface has to be declared Public?
  • What is the difference between Checked exceptions and unchecked exception?
  • What are the rules for method overloading?
  • What do you mean by threadsafe?
  • Which collection is thread-safe? What will happen when 2 or more threads will try to insert data in an arraylist in a method which is not synchronized?
  • When a method is thread safe, the thread will apply a lock on method level or Object level?
    The example of try catch and finally block with return statement?
  • Collections – Equals method vs Hashcode, use of Hashcode, best hashcode implementations, Vector vs Array list, Hashtable vs Hashmap, Generics.
  • Threads – Join(), Wait() – study all the overloaded methods of wait, Notify() and NotyfyAll(), Sleep(),synchronization.
  • String – String constant pool, Heap vs stack, Diff bet string vs string buffer
  • General – Abstract class vs Interface( which one u will choose for which scenario), Access modifiers(Public,Protected,private and default), Overriding(Including static method override).
  • Exception handling –
  • Memory – Study about JVM and Garbage collections, Memory leak, Local vs class variable
    core java design patterns(Singleton with thread safe, Factory pattern etc).
    JSP/servlets – Session handling, security, JSP implicit objects, tags.

UML:

  • What is diff between aggregation and composition? Give example
  • What is encapsulation and abstraction?
  • What is multiplicity?
  • What is polymorphism and types of polymorphism?

J2EE:

  • What is post difference between Post and Get request? When you use what?
  • What is difference between <@ include> and <jsp:include>
  • What is request forward and request redirect
  • What is difference between stateful and stateless session beans?
  • Why you have use EJBs?
  •  What is JNDI? Where you have used it? Can two connection pools have same JNDI?
  • Give 5 ANT utilities you have worked on?
  • What is M in Structs MVC? How it is implemented in struts?
  • How action servlet works ?

Hibernate:

  • What is difference between SessionFactory and Session in Hibernate?
  • What is lazy loading in hibernate? Which design pattern it follows?
  • What is meaning of cascading=alldeleteorphan in hibernate mapping file?
  • What is difference between L1 Cache and L2 Cache and how it is implemented in hibernate?
  • How you have managed DB transaction in you project? How concurrency is controlled?
  • ORM advantages & disadvantages.
  • Configuring hibernate application(sessionfactory, entity generation, entity mapping, defining named queries)
  • Criteria API.
  • Cache mechanism(first level/second level)
  • Transaction management. 

Struts:

  • Overview of MVC
  • Role of ActionServlet/Request Processor
  • The J2EE design patterns implemented by action servlet/Request processor
  • Request flow in struts
  • Different action types.

Design Pattern:

  • What is Singleton pattern? How you have implemented it? Why you use singleton pattern
  • What is Factory Pattern and why it is used?
  •  What is your understanding with connection pooling
  • Other queries based on resources skill set?

Problem Solving Approach:

  • If there is a ticket raised by the client, the page that was opening in 5 seconds yesterday, is taking 4-5 mins today. What will be your approach to resolve this issue?
  • Logic to remove duplicate character from a string and “how you will unit test your code”?

Sample questions asked by the client:

  • Difference between checked vs. unchecked, and how to create unchecked exception.
  • Hash code versus equal code.
  • Queue/topic difference.
  • What is  transactionality   when reading from JMS queues.
  • How to write a template class.
  • How to get ID’s out of a hibernate mappings.

 

 

 

Blog Author

Follow :

Related Blogs