Interview Questions and Answers - Order By Rating Q1081. Give an Example of checked and unchecked exception ? Core Java
Ans. ClassNotFoundException is checked exception whereas NoClassDefFoundError is a unchecked exception. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   exceptions   checked exceptions   unchecked exceptions   exception handling Asked in 2 Companies Ans. IndexOutofBoundException ,
NoClassDefFoundException ,
OutOfMemoryException ,
IllegalArgumentException,
NullPointerException,
IllegalStateException Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   exceptions   basic interview question basic   frequent Frequently asked to fresh graduates and less experienced. Q1083. Which of the following is tightly bound ? Inheritance or Composition ? Core Java
Ans. Inheritance. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  inheritance  object oriented programming (oops)  oops concepts   java   oops   composition  object oriented programming (oops)  oops concepts Asked in 1 Companies basic   frequent Q1084. How can we make sure that a code segment gets executed even in case of uncatched exceptions ?
Ans. By putting it within finally. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   exceptions   finally   uncatched exceptions basic   frequent Q1085. Explain the use of "Native" keyword ? Core Java
Ans. Used in method declarations to specify that the method is not implemented in the same Java source file, but rather in another language Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   native   java keywords Asked in 1 Companies Q1086. What is "super" used for ?
Ans. Used to access members of the base class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   java keywords   super   basic interview question Asked in 2 Companies basic   frequent Q1087. 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 Q1088. 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. Q1090. 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 Q1091. 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 Q1094. 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 Q1097. 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 Q1098. 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 Q1100. 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 Q1101. 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 Q1102. 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. Q1104. 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 Q1105. 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) Q1107. 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 Q1108. 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 Q1109. 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   architectureFrequently asked to fresh graduates. Q1110. 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