Top 5 Java Technical Interview Questions

Java is one of the most popular programming languages. It is a high-level, class-based, object-oriented programming language. It is used for development of web applications, including e-commerce sites, social media platforms, and enterprise-level systems. Java frameworks like spring boot are widely used in industry level software development. It is used in the top level companies like : Google, Amazon, PayPal, Airbnb, Uber, and Twitter. Let’s see top 5 interview questions asked on technical interviews : 

Question 1 : What is the meaning of each public static void main(String[] args) ?

Answer : Each part of the public static void main(String[] args) declaration in Java serves a specific purpose:

  • public : public keyword indicates that the method main is accessible from outside the class. It allows the JVM to call this method to start the execution of the program.
  • static : static keyword allows the main method to be called without creating an instance of the class. It means the method belongs to the class itself, not to instances of the class.
  • void : This keyword specifies that the main method does not return any value. It means the method will not produce a result when it finishes executing.
  • main : This is the name of the method. In Java, the main method serves as the entry point for a program. It is the method that the JVM looks for when starting the execution of a Java program.
  • String[] args : This part of the declaration is called the parameter list. It specifies the parameters that the main method accepts. In this case, String[] args indicates that the main method accepts an array of strings as arguments. These arguments can be passed to the program from the command line when it is executed. The name args can be any valid identifier, but it is a convention to use args to represent command-line arguments.
public static void main (String [] args)
public static void main (String [] args)

Question 2 : Why Java is considered as platform independent language ? 

Answer : Java is considered platform-independent primarily because two reasons : 

  • Bytecode:
    When you compile a Java source file, it’s not compiled directly into machine code for a specific platform. Rather, it’s compiled into bytecode, which is a platform-independent intermediate representation of the program.
  • Java Virtual Machine (JVM):
    The JVM is an essential component of Java’s platform independence. It’s a runtime environment that interprets and executes Java bytecode. Each platform (Windows, Linux, macOS, etc.) has its own implementation of the JVM, but they all interpret the same bytecode in the same way. This means that once a Java program is compiled into bytecode, it can run on any platform with a compatible JVM without modification

    Java uses a special kind of code called bytecode, and a tool called the Java Virtual Machine (JVM). These help Java programs work on any type of computer without needing to change the code. This is why people say you can “write once, run anywhere” in Java. It’s one big reason why Java is so popular for making all sorts of software, like websites, business programs, and phone apps.

Question 3 : What is JVM ? 

Answer : JVM stands for Java Virtual Machine. It is a abstract machine that provides runtime environment in which java bytecode can be executed. It is responsible for loading, verifying, and executing the bytecode created in Java.
 
One of the key features of the JVM is its platform independence, meaning that Java programs can run on any device or operating system as long as a compatible JVM is installed. This “write once, run anywhere” capability is a major reason for Java’s popularity in software development.
 

How JVM Works  ? 

First, Java code is compiled into bytecode. This bytecode gets interpreted on different machines. Between host system and Java source, Bytecode is an intermediary language. JVM in Java is responsible for allocating memory space.
How JVM Works ?
Working of Java Virtual Machine (JVM)

Question 4 : Why is Java not a pure object oriented language?

Answer : Java supports primitive data types like byte, boolean, char, short, int, float, long, and double, which are used for simple values and operations.

For instance:

int age = 25; // integer
boolean isStudent = true; // boolean
char grade = 'B'; // character
double salary = 40000.30; // double

Despite this support for basic data types, Java also allows the creation and manipulation of objects, like in the following example:

String name = "Arjun Gautam"; // string object
List<String> cars = new ArrayList<>(); // list object

This combination of primitive data types and objects shows Java’s versatility, but it means it’s not purely object-oriented.

Question 5 : What are the main features of OOPs? How you can implement using Java ?

Answer : The main features of Object-Oriented Programming (OOP) are:

  • Encapsulation 
  • Inheritance
  • Polymorphism
  • Abstraction
Example of Encapsulation :
Example of Inheritance :
Example of Polymorphism :
Example of Abstraction :

2 thoughts on “Top 5 Java Technical Interview Questions”

  1. I loved as much as you will receive carried out right here The sketch is attractive your authored material stylish nonetheless you command get got an impatience over that you wish be delivering the following unwell unquestionably come more formerly again since exactly the same nearly a lot often inside case you shield this hike

  2. My brother suggested I might like this website He was totally right This post actually made my day You cannt imagine just how much time I had spent for this information Thanks

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top