Top 150+ Java Interview Questions and Answers

    58 Votes

Are you preparing for Java Interview? If so, you are at the right place. This article provides frequently asked Java Interview Questions and Answers on basic & advanced topics covering all the core Java concepts like JVM, JRE, Operators, OOPs, Exceptions, IO operations, Collections etc. for Freshers and experienced Java developers.

1. What is Java technology ?

Java is a programming language, application development and deployment environment. The Java programming language is similar to C++ syntax. Java development environment provides tools for Compiling, Interpreting, Packaging the Java code.

2. What are the objectives of Java Technology ?
Java interview questions
Simple: The language syntax is based on ‘C++’ programming language. Even though the syntax of ‘C++ was adopted, some features which were troublesome were avoided to make the Java programming simple.
Object oriented: The object oriented features of Java are similar to C++. One major difference between Java and C++ lies in multiple inheritance. When C++ supports multiple inheritance, Java won't. In OOPs programming paradigm, everything is represented as Class and Objects.
Architectural Neutral: The Java compiler generates an intermediate byte code which doesn't depend on the operating system on which it is run. So the Java programs can run on any machine, irrespective of it's OS/Architecture and hence the Java program is Architectural Neutral.
Portable type: The size of Data Types is always same irrespective of the system architecture. An int in Java will always be 32 bit unlike in C/C++ where the size may be 16-bit or 32-bit depending on the compiler and machine. Java have libraries that enable to port it's application to any systems like UNIX, Windows & Macintosh systems.
Distributed: Java’s networking capabilities are both strong and easy to use. Java applications are capable of accessing objects across the net and local file system.
Secure: Since Java is mostly used in a network environment, a lot of emphasis has been placed on security to enable construction of virus & tamper free systems.
Smaller code: The Java compiler generates an intermediate byte code to make it architecture neutral. Though Java interpreter is needed to run the byte code, it is one copy per machine and not per program.
Multithreaded: Multithreading is the ability for one program to do more than one task at once. Compared to other languages it is easy to implement multithreading in Java.
Interpreted: The Java Interpreter can execute Java byte code, directly on any machine to which the interpreter has been ported. Interpreted code is slower than compiled code.

High performance: The byte codes can be translated at run time into machine code for the particular CPU on which the application is running which inturn provide high performance.

Applet programming: is one of the important features which has attracted the users of the Internet. Applets are Java programs that are typically loaded from the Internet by a browser.

3. What are the Major Features of Java Technology Architecture ?
  • Java Run Time Environment
  • Java Virtual Machine
  • Just in Time Compiler
  • Java Tools
  • Garbage Collector
Related Java Interview Questions
1. Java Collections Interview Questions
2. Java Thread Interview Questions
3. Java OOPS Interview Questions
4. Advanced Java Interview Questions
5. JSP Interview Questions
6. Servlet Interview Questions

Java Basics Interview Questions - JVM, JRE & JDK

4. What is Java Virtual Machine (JVM) ?

A self-contained operating environment that behaves as if it is a separate computer. For example, Java applets run in a Java virtual machine (VM) that has no access to the host operating system.

5. What are the advantages of JVM?

This design has two advantages:

  • System Independence: A Java application will run the same in any Java VM, regardless of the hardware and software underlying the system. 
  • Security: Because the JVM has no contact with the operating system, there is little possibility of a Java program damaging other files or applications.

6. What are classpath variables?

The classpath is an environment variable that tells the JVM where to look for user-defined classes and packages in Java programs. When a Java program is executed, JVM looks for the required classes needed for the program execution in the filesystem specified in the Classpath. Classes are loaded into the JVM, only when a call is made to use the content of the class object(Lazy Loading).

7. Explain the architecture of code execution process inside JRE ?

Java Architecture and Compilation

Java Compilers compile JAVA source code into byte code. Java Virtual Machine(JVM) interpreters Java byte code and send necessary commands to underlying hardware or Just in time compiled to native machine code and execute it directly on the underlying hardware.

Most JVM's use Just in time compilation which provides execution speeds near to C/C++ application. Most widely used JVM is Oracle Corporation's HotSpot, which is written in the C++ programming language.

8. What is Java Run Time Environment ?

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

9. What are the steps involved in Java Application Execution ?

  • Compiling Java Source Files into *.class file. (Byte Code)
  • Loading class file into Java Run Time (JRE) using class loader
  • Use Bytecode verifier to check for byte code specification
  • Use Just In time Code Generator or Interpreter for byte code execution
Page 1 of 14

Popular Videos


How to improve your Interview, Salary Negotiation, Communication & Presentation Skills.

Got a tip or Question?
Let us know

Related Articles

Java OOPS Interview Questions and Answers
Top Advanced Java Interview Questions and Answers
Java Collections Interview Questions and Answers
Java Thread Interview Questions and Answers