Introduction Oops Java Interview Questions And Answers
Oops, popularly known as Object-Oriented Programming techniques, is the programming paradigm that revolves around the concept of objects. In an OOP language such as Java, everything is an object which contains data, fields, attributes, and we code them in the form of procedures, also known as methods. It also comprises of class-based parameters which provide meaning to instances, determinant on their type. Oops, it revolves around the basic concepts of Abstraction, Polymorphism, Inheritance, Encapsulation, Objects, classes, and interfaces. Here in this post, we have compiled a list of the most commonly asked and important Oops Java interview questions and answers.
Now, if you are looking for a job related to Oops Java, you need to prepare for the 2021 Oops Java Interview Questions. Every interview is indeed different as per the different job profiles, but still, to clear the interview, you need to have a good and clear knowledge of Oops Java. Here, we have prepared the important Oops Java Interview Questions and Answers, which will help you get success in your interview.
Below are the 8 important 2021 Oops Java interview questions and answers that are frequently asked in an interview. these questions are divided into parts are as follows:
Part 1 – Oops Java Interview Questions (Basic)
This first part covers basic Interview Questions and Answers.
1. What are the different OOPs concepts?
Answer:
Different OOPs concepts are as follows:
- Polymorphism
- Abstraction
- Inheritance
- Aggregation
- Encapsulation
- Association
- Composition
2. What is polymorphism? Can we override a static method and a private method in java?
Answer:
This is the most common Oops Java Interview Question which is asked in an interview. The ability of the identification of a function during its runtime phase is called Polymorphism. In most object-oriented programming languages such as C++ and Java, there are two types of polymorphisms, compile-time polymorphism (overloading) and runtime polymorphism (overriding).
Method overloading: The ability of a method to have the same method names but different parameter numbers or types is called method overloading.
Method overriding: It occurs when the class method of a child class consists of the same name and the method signature as that of the parent class. When you override methods, the proper method is identified by the JVM to call at its program’s run time and not at the compile time.

4.8 (13,772 ratings)
View Course
No, it is impossible to override a static method in Java as the object does not bound it. On the other hand, Static methods are class-dependent and are resolved at the compile time using reference variable type. Declaring the same method inside a subclass will result in method hiding.
No, it is impossible to override a private method in java. As the private method is accessible and visible inside the class in which they are declared, they cannot be overridden inside the subclass. Though, they can be overridden inside the inner class as they can be accessed here.
Let us move to the next Oops Java Interview Questions.
3. What are some of the important Java 8 features?
Answer:
Some of the important features introduced in Java 8 are:
- forEach() method in iterable interface
- Lambda expressions and functional interfaces
- Static and default methods in interfaces
- Java time API
- Stream API for bulk data operations on collections
- Concurrency API improvements
- Collection API improvements
- Java IO improvements
- Core API improvements
4. What is the difference between State and Strategy Patterns? What problem is solved by the Strategy pattern?
Answer:
The state pattern and the strategy pattern share the same structure or class diagram; however, their intent is completely different. State patterns work on specific tasks depending on the states, while the strategy works on switching the algorithm without changing the code. For example, a method, collections.sort() sorts the object list. Since all the objects use a different comparison strategy, comparison among various objects can be made without any need of changing the sort method.
Part 2 – Oops Java Interview Questions (Advanced)
Let us now have a look at the advanced Interview Questions.
5. What are the 5 design principles for an object-oriented approach from SOLID?
Answer:
In the book Clean Code, written by Uncle Bob, each character in SOLID stands for one design principle:
S- Single Responsibility Principle
O- Open closed design principle
L- Liskov substitution principle
I – Interface segregation principle
D- Dependency inversion principle
Let us move to the next Oops Java Interview Questions.
6. Upon which OOP concept the Decorator design pattern is based?
Answer:
The decorator pattern takes advantage of the OOP feature of Composition to provide new features without the need for modifying the original class. The component is associated with the Decorator.
7. What is the difference between Association, Dependency, Composition, and Aggregation in OOP?
Answer:
In the case of an association, one class has a member variable or an attribute of the other class type, but in the case of dependency, a method is involved in an argument of the class type or in the local variable of other class types.
There are two forms of associations, aggregation and composition. Aggregation is the loose form of association where the related object survives individually, whereas, in the case of composition, the object cannot survive individually.
8. What is ThreadLocal? Do we prefer the synchronized block or synchronized method?
Answer:
All the threads of an object share the variables, so the variable is not threaded safe.
Recommended Article
This has been a guide to List Of Oops Java Interview Questions and Answers so that the candidate can crackdown these Interview Questions easily. Here in this post, we have studied about top oops java Interview Questions, which are often asked in interviews. You may also look at the following articles to learn more