Pages

Core Java Interview Questions and Answers



1. What is Java technology ?
Answer:  
Java is a programming language, application development and deployment environment. Java programming language is similar to C++ syntax. Java development environment provides tools -  Compiler, Interpreter, Packaging Tool etc.

2.What is the most Important feature of java?
Answer: 
 Java is platform independent language.

3.What do you mean by Platform Independence?
Answer: 
Platform Independence  you can run and compile program in one platform and can execute in any other platform.

4.What is JVM(Java Virtual Machine)?
Answer: 
JVM is Java Virtual Machine which is a run time Environment for the compiled java class.

5.What is JIT Compiler?
Answer: 
Just-In-Time(JIT) compiler is  used to improve the performance. JIT compiles parts of the byte code that have similar functionality at the same time,

6.Are JVM's Platform Independent?
Answer: 
JVM'S are not platform Independent. JVM'S are platform Specific.

7.What if main method declare as private?
Answer: 
No,It will compile fine but in run time it will error like main method should be in public.cannot find main method.

8.What is platform?
Answer:
 A platform is basically the hardware or software environment in which a program runs.
There are two types of platforms software and hardware.
Java provides software-based platform.

9.What all memory areas are allocated by JVM?
Answer: 
Heap, Stack, Program Counter Register and Native Method Stack

10.What is the base class of all classes?
Answer: 
java.lang.Object

11.What is javac ?
Answer: 
It produces the java byte code from *.java file.
It is the intermediate representation of your source code that contains instructions.

12.Can we mark constructors final?
Answer: 
 No, Constructor cannot be declared final.

13.What are two different ways to call garbage collector?
Answer: 
System.gc() OR Runtime.getRuntime().gc().

14.Can we override a static method?
Answer:
 No, we cannot override a static method. Static means class level.

15.Use of finalize() method in java?
 Answer: 
 finalize() method is used to free the allocated resource.

16.Is it possible to overload main() method of a class?
Answer: 
Yes, we can overload main() method as well.
But every time public static main(String[] args) will be called automatically by JVM.
Other methods need to call explicitly.

17. Does Java support operator overloading?
Answer: 
Operator overloading is not supported in Java.

18.Can I declare a data type inside loop in java?
Answer: 
 Any Data type declaration should not be inside the loop. Its possible but not recommended.

19.List two java ID Es?
Answer: 
1.Eclipse, 2.Net beans and 3.IntelliJ

20.Can we inherit the constructors?
Answer:
  No, we cannot inherit constructors.
We can call super class constructors from subclass constructor by using super() call.

21.Can this keyword be assigned null value?
Answer: 
No, this keyword cannot have null values assigned to it.

22. What is Java Run Time Environment ?

Answer:  Java Virtual Machine (JVM) along with Java Class Libraries which implement the Java application programming interface (API) form the Java Runtime Environment (JRE).

23. What is Just in Time Compiler ?

Answer:  Just in time Compiler (JIT) compiles JAVA byte code to native machine code and execute it directly on the underlying hardware. Just in time compilation which provides application execution speeds near to C or C++ application.

24. What is class loader ?
Answer: 
Class loader is used to load all the classes required execute the application into Java Virtual Machine (JVM). After the class is loaded memory required for the application is determined.

25. What are the features of OOPS?
Answer: 
Encapsulation
Abstraction
Inheritance
Polymorphism

Raj

Hello I am Dharmendra Kumar Mishra From Siwan Bihar. I am Android Application Developer and Blogger. I love to share my knowledge over Internet.

No comments: