JAVA job interview questions – top 10

Q1)Is Java Pure Object Oriented? Explain

No, Java is not considered to be pure object oriented due to the existence of primitive data types like int , double … etc

Q2)Java is Platform independent language, explain

Java Applications run inside JVM which in turn deal with OS , it’s considered to be an intermediate between Application and OS, so no matter the What is the OS to The application as long as JVM will deal with it.

Q3)Java is Both Compiled and Interpreted language, Explain

That’s true, since the Source code is compiled to .class “intermediate code” and the JVM interpret it Every time for running purpose.

Q4)What is JNI?

It’s abbreviation to Java Native Interface which is used to host non-Java code inside the Java application “like using C code inside Java application”.

Q5)What’s the signature of main method? Explain

main method is the entry gate to Java applications.

It can be written as public static void main(String[] args)

it must be static because it’s the first method that is called by the interpreter.

And public for direct accessibility.

It accept array of string as argumental main to pass value to program in runtime

Q6)What is applet?

Applet is a client side  java program that runs inside web browser by JVM.

The .class file of the applet is downloaded from the web server to the client’s machine and checking occurs for security restrictions.

Q7) What is a wrapper class?

It’s the class from which primitive is instantiated, and is used for the following reasons:

1- argument to the methods which expect object not primitive

2- for using its constants or class methods

Q8)What is a String Pool?

String objects that are created without using the new keyword is said to belong to String pool . i.e. no new allocation for the string in the memory, it use the existed one , if existed or create new if not available.

Q9) What is The Enhanced-For?

It’s iteration over a collection  with an identified of the same type of iterable-expression

it can be like :

for(type identifier : iterable_expression){}

10) What’s the different between static method and static variable?

Static method can be invoked directly using class name without instantiation,as it make no use of the constructor to be invoked using it.

While static variable is a variable that exists only once in the memory “only one copy” like website counters.

11) What is abstract class?

It’s a class created only for the purpose of inheritance, it can’t be instantiated as it contain no constructors, it must contain at least on abstract method which will be overridden in the class children.

12) How to Handle Exception in Java?

Exception is handled by one of two ways,

the first is to throw the exception to the caller method to handle it by using throws keyword

the second way is to catch the exception in the place of occurrence by using try , catch , finally where code in finally will be executed wither exception occurred or not.

Leave a Reply

Your email address will not be published.