Java is one of the most efficient programming languages known. It has a vast scope. Its versatile features make it extremely popular among the application developers. A career in the field of application development in Java is good and rewarding. If you have sound knowledge of this language, then the career option of a Java Developer has surely a lot to offer you both in terms of exposure and money.
I am here providing few important interview questions that are generally asked by an employer:
1. What is the most striking feature of Java language?
Java is a platform independent language. An intermediate code called byte code is generated while a java program is compiled. This byte code can then be executed at any machine. Hence the code is portable.
2. Can you list four concepts of OOPs?
The four basic OOPs concepts are:
1. Encapsulation.
2. Polymorphism.
3. Inheritance.
4. Abstraction.
3. Differentiate between method overriding and overloading?
Overriding methods have same name and signature. Overloading methods have same name but are distinguished by the compiler according to their return type and argument type and their number. In case of overriding, the behavior of the subclass gets monitored by its parent class.
4. What is an Interface?
An Interface is used for implementing the concept of multiple inheritance. More than one interface can be derived in a class. An Interface can declare constants and instance methods, but cannot give a behavior to them.
5. Why is the keyword “protected” used?
The protected keyword makes a method or field accessible to its own class, its sub class and all the classes that are in the same package.
6. Hash Map and Map are same or different concepts?
Map is an interface and Hash Map is the class that implements it.
7. State the difference between throw and throws.
The difference between throw and throws is as under:
1. Throws: a method capable of throwing a checked exception uses throws clause in its signature.
2. Throw: the method that throw an exception object use throw clause in it’s body. It creates an exception object within the method body.
8. How can we implement a thread?
We can implement a thread by two ways:
1. By implementing Runnable Interface
2. Inheriting from a Thread class
Using the method of Interface is advantageous for situations where multiple inheritance needs to be done.
These are the few important interview questions that are generally asked by an employer for a Java developer job. All the Best!