Interview Questions and Answers - Order By Rating Q2131. 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 Ans. finalize() method is called just before an object is destroyed. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   finalize   garbage collection   basic interview question Asked in 1 Companies basic   frequent Try 1 Question(s) TestVery frequently asked in phone and walk in interviews. Q2133. What are Marker Interfaces ? Name few Java marker interfaces ? Core Java
Ans. An interface without any method declaration is called as marker interface. there are 3 in-built interfaces in JVM i.e. serializable, clonable, remote Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   interfaces   marker interface   serializable   clonable Asked in 21 Companies intermediate   frequent Try 1 Question(s) Test Q2134. Is runnable a Marker interface ? Core Java
Ans. No , it has run method declared. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   interfaces   marker interface   runnable   yes-noFrequently asked to fresh graduates. Ans. Process is a program in execution whereas thread is a separate path of execution in a program. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   threads   multi threading   operating system   process vs thread Asked in 24 Companies basic   frequent Frequently asked to fresh graduates. Ans. When two threads are waiting each other and cant precede the program is said to be deadlock. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   threads   multi threading   operating system   deadlock  concurrency Asked in 23 Companies basic   frequent Q2137. 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. Autoboxing is the automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper classes Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   java5   autoboxing   wrapper classes Asked in 2 Companies basic   frequent Ans. 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 Q2140. 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 Q2141. 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 Q2143. 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 Q2144. 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 Q2145. Can we declare interface methods as private ?
Ans. With Java 9 we can declare interface methods as private Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   interfaces   yes-no   privateAns. 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 Very frequently asked. Usually difference between String,StringBuffer and StringBuilder is asked in different variations. Q2147. Difference between StringBuffer and StringBuilder ? Core Java
Ans. StringBuffer is synchronized whereas StringBuilder is not. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   string   stringbuffer   string class   stringbuilder   synchronized   basic interview question   infosys technologies Asked in 17 Companies basic   frequent Try 1 Question(s) Test Q2148. 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   synchronizedVery frequently asked in different variations. Frequently asked in Deloitte ( 2 feedback ) , HCL Tech ( 3 feedback ), TCS and Coginizant (CTS) Q2150. Explain the scenerios to choose between String , StringBuilder and StringBuffer ?
or
What is the difference between String , StringBuilder and StringBuffer ? Core Java
Ans. If the Object value will not change, use String Class because a String object is immutable.
If the Object value can change and will only be modified from a single thread, use StringBuilder because StringBuilder is unsynchronized(means faster).
If the Object value may change, and can be modified by multiple threads, use a StringBuffer because StringBuffer is thread safe(synchronized). Sample Code for String Sample Code for StringBuffer Sample Code for StringBuilder Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   string class   string   stringbuilder   stringbuffer   String vs StringBuffer   String vs StringBuilder   String vs StringBuilder vs StringBuffer   StringBuffer vs stringBuilder Asked in 29 Companies basic   frequent Try 3 Question(s) Test Q2151. Explain java.lang.OutOfMemoryError ? Core Java
Ans. This Error is 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. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   exceptions   jvm   outofmemoryerror Asked in 1 Companies Q2152. 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 Q2153. 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. Q2154. 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 Q2155. Difference between implicit and explicit type casting ?
Ans. An explicit conversion is where you use some syntax to tell the program to do a conversion whereas in case of implicit type casting you need not provide the data type. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   casting Q2156. Difference between loadClass and Class.forName ?
Ans. loadClass only loads the class but doesn't initialize the object whereas Class.forName initialize the object after loading it. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   class loaders   jvm   advanced Q2157. Should we override finalize method ?
Ans. Finalize is used by Java for Garbage collection. It should not be done as we should leave the Garbage Collection to Java itself. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   garbage collection   java memory management   finalize Try 2 Question(s) Test Q2158. Difference between Factory and Abstract Factory Design Pattern ? Design
Ans. Factory Pattern deals with creation of objects delegated to a separate factory class whereas Abstract Factory patterns works around a super-factory which creates other factories. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   design pattern   factory design pattern   abstract factory design pattern   factory vs abstract factory expert Q2159. Difference between Factory and Builder Design Pattern ? Design
Ans. Builder pattern is the extension of Factory pattern wherein the Builder class builds a complex object in multiple steps. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   design pattern   factory design pattern   builder design pattern Asked in 1 Companies expert Q2160. 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