Professional Documents
Culture Documents
By www.bestonlinetrainers.com
Q1: To implement key Object in HashMap which two methods are used?
Answer: In HashMap, to use any object as Key it must implement equals and HashCode method in Java.
www.bestonlinetrainers.com
www.bestonlinetrainers.com
Q6: While writing stored procedure or accessing stored procedure from java how is the error condition handled?
Answer: This is one of the tough questions normally asked in Java interview. The stored procedure should return error code if some operation fails but if stored procedure itself fails than catching SQLException is the only choice left .
Q7: At the compile time are the imports checked for validity? That is, will the code containing an import such as java.lang.ABCD compile up?
Answer: Yes. The imports are checked for the semantic validity at the compile time. The above line of import will not compile if it has the code, an error is shown saying, cannot resolve symbol. Symbol: class ABCD Location: package io Import java.io.ABCD;
Q9: What is the difference between factory and abstract factory pattern?
Answer: One more level of abstraction is provided by Abstract Factory .Different factories from each Abstract Factory responsible for the creation of different hierarchies of objects based on type of factory are considered. For example; Abstract Factory extended by AutomobileFactory, UserFactory, RoleFactoryetc.For every object created in that genre, each individual factory would be responsible.
Q10: Define Singleton? Which is better: to make whole method synchronized or only critical section synchronized?
Answer: Singleton in JAVA is a class with just one instance in the whole Java application. One such example is java.lang.Runtime is a Singleton class .With the introduction Enum by Java 5, creating a Singleton is easy rather than being tricky as earlier.