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
Local Variables | Instance Variables | |
---|---|---|
1. | Declared in constructor, method or block. | Declared in a class |
2. | Not possible to use access modifiers | Access modifiers can be given |
3. | Visible within the declared method | Visible for all methods |
4. | No default value | Have default values |
It is a prototype or user-defined blueprint that is used to create objects or data types. A class represents properties or methods that are common to objects of one type. All class objects possess the class properties.
It is the core unit of Object-Oriented Programming and represents real entities. As we know, a Java program creates objects that interact by invoking various methods.
An object consists of state, behavior, and identity.
The constructor is a method used to initialize an object. A normal java method has return type but the constructor does not have any explicit return type. It is called during the object creation time.
There is two type of Constructors - Default or no-arg Constructor, Parameterized Constructor.
It is a reference variable that refers to the current object. It can be used as follows:
- To refer instance variable of class
- To invoke class constructor
- Passed as an argument in method call
- Passed as an argument in the constructor call
- Used to return a class instance
It is the process when one class acquires the properties or methods or fields of another class. This process is used to arrange and manage information in hierarchical order. The class that inherits the properties is called subclass. The class whose properties get inherited is called superclass.
It is one of the features of object-oriented programming that allows the developers to perform one action in different ways. Developers often use Polymorphism in referencing a parent class to a child class object.
Method overriding is a feature in object-oriented programming that allows a child class to give a specific implementation method that is already given by its parent classes.
Method Overloading allows a class to have more than one methods of having the same name, but only if the argument lists are varying. This feature is similar to constructor overloading feature that allows more than one constructor to a class only if their argument lists are different.
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