Interview Questions and Answers - Order By Rating Ans. URL is Uniform Resource Locator which is representation of HTTP address. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  j2ee   http   internet   url basic   rare Ans. HTTP or Hypertext Transfer Protocol is internet protocol for tranmission of hypertext ( text with meta data ) over internet. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  j2ee   http   internet  fidelity Asked in 2 Companies basic   frequent Very frequently asked to Fresh graduates. Q183. What is the difference between Encapsulation and Abstraction? Core Java
Ans. 1.Abstraction solves the problem at design level while encapsulation solves the problem at implementation level
2.Abstraction is used for hiding the unwanted data and giving relevant data. while Encapsulation means hiding the code and data into a single unit to protect the data from outside world.
3. Abstraction lets you focus on what the object does instead of how it does it while Encapsulation means hiding the internal details or mechanics of how an object does something.
4.For example: Outer Look of a Television, like it has a display screen and channel buttons to change channel it explains Abstraction but Inner Implementation detail of a Television how CRT and Display Screen are connect with each other using different circuits , it explains Encapsulation. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   oops concepts   encapsulation  object oriented programming (oops)  oops concepts   abstraction   basic interview question   encapsulation vs abstraction Asked in 10 Companies basic   frequent Try 2 Question(s) Test Q184. Explain static blocks in Java ? Core Java
Ans. A static initialization block is a normal block of code enclosed in braces, { }, and preceded by the static keyword. Here is an example:
static {
// whatever code is needed for initialization goes here
}
A class can have any number of static initialization blocks, and they can appear anywhere in the class body. The runtime system guarantees that static initialization blocks are called in the order that they appear in the source code. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   static   static block Asked in 16 Companies basic   frequent Q185. Which access specifier can be used with Class ? Core Java
Ans. For top level class we can only use "public" and "default". We can use private with inner class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   class   access specifier   inner classes basic   frequent Q186. Explain Annotations ?
Ans. Annotations, a form of metadata, provide data about a program that is not part of the program itself. Annotations have no direct effect on the operation of the code they annotate. Annotations have a number of uses, among them: • Information for the compiler — Annotations can be used by the compiler to detect errors or suppress warnings. • Compile-time and deployment-time processing — Software tools can process annotation information to generate code, XML files, and so forth. • Runtime processing — Some annotations are available to be examined at runtime. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   annotations basic   frequent Q187. Difference between Abstract and Concrete Class ? Core Java
Ans. Abstract classes are only meant to be sub classed and not meant to be instantiated whereas concrete classes are meant to be instantiated. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   abstract classes   Abstract vs Concrete Class Asked in 1 Companies basic   frequent Very Frequently asked to fresh graduates and less experienced. Favorite question in Walk in drives. Frequently asked in Indian Services companies. Q188. Difference between Overloading and Overriding ? Core Java
Ans. Overloading - Similar Signature but different definition , like function overloading.
Overriding - Overriding the Definition of base class in the derived class. Sample Code for overloading Sample Code for overriding Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   overloading   overriding   oops concepts   basic interview question   overloading vs overriding Asked in 86 Companies basic   frequent Try 1 Question(s) Test Q189. Difference between Vector and ArrayList ? Core Java
Ans. Vectors are synchronized whereas Array lists are not. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   basic interview question   vector   arraylist   collections   synchronization   vector vs arraylist Asked in 35 Companies basic   frequent Q190. Different ways of implementing Threads in Java ? Core Java
Ans. Threads in Java can be implement either by Extending Thread class or implementing runnable interface. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   threads   multi threading Asked in 1 Companies basic   frequent Frequently asked in Cognizant (CTS) Q191. What is Serialization ? Why do we need it ? Core Java
Ans. Storing the state of an object in a file or other medium is called serialization.
Classes can communicate only if they are built together ( as they need Byte code for communication ). What if we need to enable communication between different applications ( i.e they have been built independently or even they reside at different locations ), We need a mechanism that will transfer the Bean state to a Medium than can be transferred to the receiving application. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   serialization Asked in 18 Companies basic   frequent Try 1 Question(s) TestAns. A Method that cannot be overriden in the sub class. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   java keywords   final   final method   overriding   basic interview question basic   frequent Try 1 Question(s) TestVery Frequently asked.Favorite question in Walk in drive for many Indian service companies. Q193. What is a Final Class ?
Ans. A Class that cannot be sub classed. Sample Code for final class Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   final   final class   java keyword   basic interview question Asked in 3 Companies basic   frequent Very frequently asked. Usually asked with questions related to String. Frequently asked at CTS / Cognizant Ans. Object that can't be changed after instantiation. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   immutable  immutability Asked in 27 Companies basic   frequent Try 2 Question(s) TestVery Frequently asked. Usually asked along with String Class related questions. Ans. Class using which only immutable (objects that cannot be changed after initialization) objects can be created. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   immutable  immutability   immutable  immutability class   string class   basic interview question Asked in 18 Companies Basic   frequent Try 2 Question(s) TestAns. 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. Q197. 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 Q198. 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 Q199. 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 Q200. 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 Q201. 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) TestFrequently 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 Q205. 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) TestAns. 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. Q209. 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 Q210. 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