Java interview questions and Answers
Java is a computing platform as well as a programming language. You can download it for free. An object-oriented language, Java is a fast, secure and easily extendible language. Java is said to be more dynamic than C or C++ language because of its adaptable design. Unlike many other programming languages, Java is a platform-independent and Architecture-neutral language. Our massive collection of java interview questions will definitely help you find a great job.
Most Frequently Asked Java interview questions
An anonymous class is like a local class or an inner class, but without a name. You can use an anonymous class for declaring and instantiating a class simultaneously.
Java.lang.Throwable
Java is a computing platform as well as a programming language. An object-oriented language, Java is a fast, secure and easily extendible language. Java is a platform independent and Architecture-neutral language.
It is used to create complete & powerful applications that may run on a single computer or be distributed among clients and servers in a network. I also can be used on the intranet applications.
C++ | Java | |
---|---|---|
1. | Follows WOCA approach (Write once, compile anywhere). | Follows WORA approach (Write once, run anywhere). |
2. | Runs as code on native machine. | Runs on virtual machines. |
3. | Multiple binary compatibility standards are included. | Has single binary compatibility standard. |
4. | All types of Pointers and pass-by-value are supported. | Primitive and reference types are only passed by value. |
Java Programming language was created by James Gosling at sun micro systems in 1991.
It is a virtual machine that enables computers to run Java programs in addition to programs written in other languages but are compiled to Java bytecode. OpenJDK project has developed the Java virtual machine (JVM) reference as open source code. The reference includes a JIT compiler which is known as HotSpot.
Java Development Kit (JDK) | JVM | JRE | |
---|---|---|---|
1. | Core component of Java Environment | Converts Byte code to machine-specific code | Implementation of JVM. |
2. | Provides tools and executables required for a Java Program | Platform dependent | Provides a platform for executing Java programs. |
3. | It is platform specific | Provides core functions like garbage collection, memory management and security etc. | Consists of java binaries and classes. |
Class loaders are responsible for dynamically loading the classes during the runtime to the JVM. They are a part of the JRE.
Three types of Class Loaders are built-in - Bootstrap, Extensions and System.
Following are the advantages:
- Allow you to define packages for bundling a group of classes or interfaces.
- No name conflicts with other package names.
- Packages make access control easier
- Packages make access control easier
Object-Based Languages | Object-Oriented Languages | |
---|---|---|
1. | Does not support inheritance or polymorphism. | Supports polymorphism and inheritance |
2. | Does not support built-in objects. | Support built-in objects. |
3. | Examples - Javascript and VB | Examples - C# and Java |
Development History of Java Programming Language
Sun Microsystems released its first version in 1995 as a core component of its platform. Majority of candidates are asked this information in advanced java interview questions.
Latest Version: The latest version is Java SE 11 (18.9 LTS), which was released in September 2018. This information is critical if you are preparing for Java interview questions.
Advantages of Java
- Simple and easy to learn
- Robust and multithreaded
- Enables high performance
- Follows WORA (write once, run anywhere) approach