GnuDeveloper.com

Core Java Interview questions

In java why Object class needs to be inherited by default?
For polymorphism we need a common one base class (Object class) should be available to receive any user custom class
Example: The println method public void println(Object x) { }
System.out.println(new student());

•In java when class will implicitly inherit Object class ?
Answer: when a class does not extends base class then Object class will be extended

•what is weak references and strong references ?
Strong reference : Not eligible for garbage collection
Weak reference: Eligible for garbage collection means if not used object assign to null value

•How to handle Error & Exception in java ?
•How to measure the code coverage ?
•what are the immutable objects in java ?
Answer: Strings , All Wrapper class like Integer, Long

• what is association , aggregation, composition ?
• how Method Overloading for NULL parameter work?
• what is marker interface ?
• How to find First Non-Repeated Character from String using less iteration
• Difference between java 1.5 ,1.6, 1.7, 1.8?
• Hashmap depends upon which object method ?
Answer : hashcode and equals

• How to find first non- repeatable character in the string ?
• when to use IdentityHashMap or SortedMap ?
• Abstract class is created in design phase or implementation phase of sdlc ?
• How to make hasp map to sync?
• when to use Serialization ?
As a communication mechanism,As a persistence mechanism

• what are the types of exception ?
Checked : It is done in compile time like FileNotFoundException
UnChecked : it is done in run time like NullPointerException, OutOfMemoryError

• what is Polymorphism , how it can be done in Java?
interface shape{}
class rectangle implements shape
Shape obj = new Rectangle();
• Object class, is it interface or abstract?
• Can we overload static method?
• Can we overload private method?
• What is the use of volatile keyword?
• How to find the duplicate value in the list with simple search not 2 for loop?
• Difference Runtime exception and error?
• How to skip the finally block in a method?
• Type of lock available in java?
• How do you define thread model?
• How to handle Java concurrent modification exception?
• How to maintain Hibernate version of data object?
• What happens if you call destroy () in java servlets?
• Different between equal & equals?
• Life cycle of servlets?
• How to get modified data from DB in hibernate when modifications done outside hibernate?
• Keyword vs reserved word?
• When to use Hashcode ?
• What happens when duplicate value inserted in set class?
• when will we get handshake exception ?
• Does the clone object has same hashcode by default?
• What is the code name for java 7,8?
Java 7 = Dolphin.
Java 8 = NA, Naming convention stopped from java 8
• what is the diffference Deep Copy and Shallow Copy in Java Object cloning?

Groups: