Interview Questions and Answers - Order By Newest Q301. What is "this" keyword used for ?
Ans. Used to represent an instance of the class in which it appears. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   java keywords   this   basic interview question basic   frequent Q302. Difference between boolean and Boolean ? Core Java
Ans. boolean is a primitive type whereas Boolean is a class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   wrapper classes   boolean vs Boolean basic   rare Q303. Difference between Serialization and Deserialization ? Core Java
Ans. Serialization is the process of writing the state of an object to a byte stream. Deserialization is the process of restoring these objects. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   serialization   deserialization   serialization vs deserialization Asked in 2 Companies basic   frequent Try 1 Question(s) TestAns. An enum type is a special data type that enables for a variable to be a set of predefined constants Sample Code for enum Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java5   enum   basic interview question basic   frequent Try 2 Question(s) Test Q305. What are Wrapper Classes ? What are Primitive Wrapper Classes ? Core Java
Ans. A wrapper class is any class which "wraps" or "encapsulates" the functionality of another class or component. A Wrapper Class that wraps or encapsulates the primitive data type is called Primitive Wrapper Class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   wrapper classes   primitive wrapper classes Q306. What Design pattern Wrapper Classes implement ? Design
Ans. Adapter. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   wrapper classes   adapter design pattern   design patternAns. Enables the programmer to abbreviate the names of classes defined in a package. Sample Code for import Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   import   java keyword Q308. Different types of memory used by JVM ? Core Java
Ans. Class , Heap , Stack , Register , Native Method Stack. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   jvm   memory management   memory   advanced   architecture   technical architect Asked in 1 Companies intermediate   frequent Try 5 Question(s) Test Q309. What is a class loader ? What are the different class loaders used by JVM ? Core Java
Ans. Part of JVM which is used to load classes and interfaces.
Bootstrap , Extension and System are the class loaders used by JVM. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   class loaders  classloaders   jvm   java memory management   advanced Asked in 3 Companies Ans. By static import , we can access the static members of a class directly without prefixing it with the class name. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java5   static import   static   java keyword   static import Asked in 4 Companies basic   frequent Q311. Difference between Map and HashMap ? Core Java
Ans. Map is an interface where HashMap is the concrete class. Sample Code for map Sample Code for hashmap Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   hashmap   map basic   frequent Ans. The properties class is a subclass of Hashtable that can be read from or written to a stream. Sample Code for Load Properties using Property Class Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   collections   hashtable   map   synchronization   synchronized Q313. Can we have multiple servlets in a web application and How can we do that ? Java EE
Ans. Yes by making entries in web.xml Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  j2ee   servlets   servelets   web application   java   web.xml   yes-no   architecture Q314. How can we manage Error Messages in the web application ? Solution
Ans. Within message.properties file. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  j2ee   web application   struts   spring Asked in 1 Companies Frequently asked to fresh graduates. Q315. Is JVM, a compiler or interpretor ?
Ans. Its an interpretor. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   jvm   compiler   interpretor basic   frequent Q316. Difference between Proxy and Adapter ? Design
Ans. Adapter object has a different input than the real subject whereas Proxy object has the same input as the real subject. Proxy object is such that it should be placed as it is in place of the real subject. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   design pattern   proxy   adapter   proxy vs adapter expert Q317. Difference between Adapter and Facade ? Design
Ans. The Difference between these patterns in only the intent. Adapter is used because the objects in current form cannot communicate where as in Facade , though the objects can communicate , A Facade object is placed between the client and subject to simplify the interface. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   design pattern   adapter   facade expert Q318. Example of Chain of Responsibility Design Pattern ?
Ans. Exception Handling Throw mechanism. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   design pattern   chain of responsibility expert Q319. Example of Observer Design Pattern ?
Ans. Listeners. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   design pattern   listeners   observer design pattern expert Q320. Which kind of memory is used for storing object member variables and function local variables ?
Ans. Local variables are stored in stack whereas object variables are stored in heap. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   jvm   memory management   stack memory   heap memory expert Q321. Why do member variables have default values whereas local variables don't have any default value ? Core Java
Ans. member variable are loaded into heap, so they are initialized with default values when an instance of a class is created. In case of local variables, they are stored in stack until they are being used. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   jvm   memory management   variables   stack memory   heap memory   default values expert Q322. Is it necessary that each try block to be followed by catch block ? Core Java
Ans. It should be followed by either catch or finally block. Sample Code for Retry in case of exception Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   exceptions   exception handling   try   catch   finally  Oracle OCA Test Asked in 3 Companies basic   frequent Try 1 Question(s) Test Q323. What is exception propogation ? Core Java
Ans. Passing the exception object to the calling method. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   exceptions   exception handling   throw Q324. Difference between nested and inner classes ?
Ans. Inner class is a type of nested class.
Inner classes are non static nested classes i.e the one that are associated with the instance of outer class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   static   nested classes   inner classes   nested vs inner class basic   frequent Try 1 Question(s) Test Q325. What is a nested interface ?
Ans. Any interface declared inside a class or an interface. It is static by default. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   nested classes Q326. What is an Externalizable interface ?
Ans. Externalizable interface is used to write the state of an object into a byte stream in compressed format. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   serialization   externalizable interface   interface Asked in 3 Companies Q327. Difference between serializable and externalizable interface ?
Ans. Serializable is a marker interface whereas externalizable is not. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   serialization   externalizable   interface   marker interface Q328. Can we instantiate the object of derived class if parent constructor is protected ? Core Java
Ans. Yes, as protected constructor is accessible in sub class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   constructor   access specifier   protected   yes-no  private constructor Q329. Can we declare an abstract method private ?
Ans. No Abstract methods can only be declared protected or public. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   abstract   oops   access specifier   private   yes-no intermediate   rare Q330. What are the design considerations while making a choice between using interface and abstract class ? Core Java
Ans. Keep it as a Abstract Class if its a "Is a" Relationsship and should do subset/all of the functionality. Keep it as Interface if its a "Should Do" relationship. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   abstract classes   interfaces   advanced Asked in 3 Companies