Top 150+ Java Interview Questions and Answers
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.
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.
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.
- Java Run Time Environment
- Java Virtual Machine
- Just in Time Compiler
- Java Tools
- Garbage Collector
Java Basics Interview Questions – JVM, JRE JDK
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 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.
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