OOPS Interview Question Bank
OOPS Interview Question Bank
OOPS Interview Question Bank
world, therefore, every interview that you attend requires knowledge of OOPs. This
article compiles the most frequently asked OOPs Interview Questions for freshers
which will help you ace your interviews. So go ahead and get prepared.
Inheritance
Encapsulation
Polymorphism
Data Abstraction
An object is a real-world entity which is the basic unit of OOPs for example chair, cat,
dog, etc. Different objects have different states or attributes, and behaviors.
6. What is a class?
A class is a prototype that consists of objects in different states and with different
behaviors. It has a number of methods that are common the objects present within
that class.
Yes, you can call the base class without instantiating it if:
It is a static method
The base class is inherited by some other subclass
Object Class
Objects take memory space when they are A class does not take memory space when
created created
To know more about objects and classes in JAVA, Python, and C++ you can go
through the following blogs:
Objects in Java
Class in Java
Objects and classes in Python
Objects in C++
Single inheritance
Multiple inheritance
Multilevel inheritance
Hierarchical inheritance
Hybrid inheritance
12. What is the difference between multiple and multilevel inheritance?
Multiple Inheritance Multilevel Inheritance
Increases the time and effort required to execute a program as it requires jumping
back and forth between different classes
The parent class and the child class get tightly coupled
Any modifications to the program would require changes both in the parent as well as
the child class
Needs careful implementation else would lead to incorrect results
Polymorphism refers to the ability to exist in multiple forms. Multiple definitions can
be given to a single interface. For example, if you have a class named Vehicle, it can
have a method named speed but you cannot define it because different vehicles
have different speed. This method will be defined in the subclasses with different
definitions for different vehicles.
To know more about polymorphism in Java and Python, read the below articles:
Polymorphism in Java
Polymorphism in Python
27. What is the difference between public, private and protected access modifiers?
Accessibility from own Accessibility from Accessibility from
Name
class derived class world
Encapsulation in Java
Encapsulation in C++
Encapsulation in Python
Data abstraction
Abstract class
Abstract method
Solves the problem at the design level Solves the problem at the implementation
level
Allows showing important aspects while Binds code and data together into a single
hiding implementation details unit and hides it from the world
To know more about data abstraction, below articles might help you:
Abstraction in Java
Abstraction in Python
Default constructor
Parameterized constructor
Copy constructor
Static constructor
Private constructor
A class is basically a template that binds the Callable set of instructions also called a
code and data together into a single unit. procedure or function that are to be
Classes consist of methods, variables, etc performed on the given data
Error Exception
Errors are problems that should not be Conditions that an application might try
encountered by applications to catch
48. What is a try/ catch block?
A try/ catch block is used to handle exceptions. The try block defines a set of
statements that may lead to an error. The catch block basically catches the
exception.
A finally block consists of code that is used to execute important code such as
closing a connection, etc. This block executes when the try block exits. It also makes
sure that finally block executes even in case some unexpected exception is
encountered.