Java Interview Questions

Java Interview Questions

  • What is difference between JDK, JRE and JVM?

a.JVM – VM is an acronym for Java Virtual Machine, It is an abstract machine, which provides the runtime environment in which java bytecode can be executed. It is a specification.

JVMs are available for many hardware and software platforms (so JVM is platform dependent)

b.JRE – JRE stands for Java Runtime Environment. It is the implementation of JVM

c.JDK – JDK is an acronym for Java Development Kit. It physically exists. It contains JRE + development tools

 

  • How many types of memory areas are allocated by JVM?

Many types:
1.Class(Method) Area
2.Heap
3.Stack
4.Program Counter Register
5.Native Method Stack

Java Interview Questions

  • What is JIT compiler?

Just-In-Time (JIT) compiler: It is used to improve the performance. JIT compiles parts of the byte code that have similar functionality at the same time, and hence reduces the amount of time needed for compilation.Here the term “compiler” refers to a translator from the instruction set of a Java virtual machine (JVM) to the instruction set of a specific CPU

  • What is platform?

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

                                                                                                                                     Java Interview Questions

  • What is the main difference between Java platform and other platforms?

a.The Java platform differs from most other platforms in the sense that it’s a software-based platform that runs on top of other hardware-based platforms. It has two components:
1.Runtime Environment
2.API(Application Programming Interface)

  • What gives Java its ‘write once and run anywhere’ nature?

The bytecode. Java is compiled to be a byte code that is the intermediate language between source code and machine code. This byte code is not platform specific and hence can be fed to any platform

  Java Interview Questions

  • What is classloader?

The classloader is a subsystem of JVM that is used to load classes and interfaces. There are many types of classloaders e.g. Bootstrap classloader, Extension classloader, System classloader, Plugin classloader etc.

 

  • Is Empty .java file name a valid source file name?

Yes, save your java file by .java only, compile it by javac .java and run by java yourclassname Let’s take a simple example:
//save by .java only
class A{
public static void main(String args[]){
System.out.println(“Hello java”);
}
}
//compile by javac.java
//run by java A
compile it by javac.java
run it by java A

                                                                                                                                     Java Interview Questions

  • Is delete, next, main, exit or null keyword in java?

No.

  • If I don’t provide any arguments on the command line, then the String array of Main method will be empty or null?

It is empty. But not null

  • Explain public static void main(String args[]).

public : Public is an access modifier, which is used to specify who can access this method. Public means that this Method will be accessible by any Class.
static : It is a keyword in java which identifies it is class based i.e it can be accessed without creating the instance of a Class.

void : It is the return type of the method. Void defines the method which will not return any value.

main: It is the name of the method which is searched by JVM as a starting point for an application with a particular signature only. It is the method where the main execution occurs.

String args[] : It is the parameter passed to the main method.

  • Why Java is platform independent?

Platform independent practically means “write once run anywhere”. Java is called so because of its byte codes which can run on any system irrespective of its underlying operating system.

  • Why java is not 100% Object-oriented?

Java is not 100% Object-oriented because it makes use of eight primitive datatypes such as boolean, byte, char, int, float, double, long, short which are not objects.
Java Interview Questions

  • What is association?

Association is a relationship where all object have their own lifecycle and there is no owner. Let’s take an example of Teacher and Student. Multiple students can associate with a single teacher and a single student can associate with multiple teachers but there is no ownership between the objects and both have their own lifecycle. These relationship can be one to one, One to many, many to one and many to many.

  • What do you mean by aggregation?

Aggregation is a specialized form of Association where all object have their own lifecycle but there is ownership and child object can not belongs to another parent object. Let’s take an example of Department and teacher. A single teacher can not belongs to multiple departments, but if we delete the department teacher object will not destroy.

  • What are the JDBC API components?

The java.sql package contains interfaces and classes for JDBC API.
Interfaces:
Connection
Statement
PreparedStatement
ResultSet
ResultSetMetaData
DatabaseMetaData
CallableStatement etc.
Classes:
DriverManager
Blob
Clob
Types
SQLException etc.

  • What is the role of JDBC DriverManager class?

The DriverManager class manages the registered drivers. It can be used to register and unregister drivers. It provides factory method that returns the instance of Connection.

KyrosAcademy

This information box about the author only appears if the author has biographical information. Otherwise there is not author box shown. Follow YOOtheme on Twitter or read the blog.
+91 9952948899 info@kyrosacademy.com

Offcanvas