Java Interview Questions

Java Interview Questions

1.What is Java?
Ans. Java is the high-level, object-oriented and secure programming language. It is a platform-independent, high performance, Multithreaded language. Java is also known as the platform as it provides its own JRE and API.

2. What is use of Java?
Ans. Java programming is used everywhere. We use Java programming to create standalone programs, web applications, and web services. We can also create a distributed enterprise applications using Java EE frameworks.

3. What is the platform?
Ans. A platform is the hardware or software environment where a piece of software is executed. There are 2 types of platforms, software-based platform and hardware-based platform. Java provides the software-based platform.

4. Define class?
Ans. A class is a blue print from which an individual objects are created. A class can contain fields and methods to describe the behavior of an object.

5. What is Core Java?
Ans. Java SE is also called as Core Java. Core Java is a set of libraries which are a part of standard java installation. For example, the Collections framework is part of Core Java. But, Servlet/JSP is part of Java Enterprise Edition.

6. What is a ClassLoader?
Ans. A classloader is a subsystem of Java Virtual Machine, and it is dedicated to loading class files when a program is executed; ClassLoader is the first to load the executable file. Java has Bootstrap, Extension, and Application classloaders.

7. What is the default value of the local variables?
Ans. The local variables in Java are not initialized to any default value, neither primitives nor object references.

8. What are the Memory Allocations in Java?
Ans. Java has 5 types of memory allocations.
Class Memory
Stack Memory
Heap Memory
Program Counter-Memory
Native Method Stack Memory

9. What are the advantages of Packages in Java?
Ans. The advantages of defining packages in Java are
It is easier to locate the related classes.
The Package provides easier access control.
Packages avoid the name clashes.
We can also have the hidden classes that are not visible outside and used by the package.

10. What is Copy Constructor in Java
Ans. A Copy Constructor is a constructor which initializes an object through another object of the same class.