Top 50 OOPs Interview Questions & Answers (2022 Update)

Following are frequently asked Interview Questions for freshers arsenic well as an have .net/ Java/Python Software Developers .
1) What is OOPS?

OOPS is abbreviated as Object Oriented Programming organization in which programs are considered as a solicitation of objects. Each object is nothing but an exemplify of a classify .
2) Write basic concepts of OOPS?
Following are the concepts of OOPS :

  1. Abstraction
  2. Encapsulation
  3. Inheritance
  4. Polymorphism

3) What is a class?
A class is simply a representation of a type of object. It is the blueprint/plan/template that describes the details of an object .
4) What is an Object?
An object is an exemplify of a classify. It has its own state of matter, demeanor, and identity .
5) What is Encapsulation?
encapsulation is an assign of an object, and it contains all data which is hidden. That hide data can be restricted to the members of that class .
Levels are Public, Protected, Private, Internal, and Protected Internal .
6) What is Polymorphism?
polymorphism is nothing but assigning behavior or value in a subclass to something that was already declared in the main course. Simply, polymorphism takes more than one form .
7) What is Inheritance?
inheritance is a concept where one class shares the structure and behavior defined in another course. If Inheritance applied to one class is called Single Inheritance, and if it depends on multiple classes, then it is called multiple Inheritance .
8) What are manipulators?
Manipulators are the functions which can be used in conjunction with the interpolation ( < < ) and extraction ( > > ) operators on an object. Examples are endl and setw .
9) Explain the term constructor
A builder is a method used to initialize the country of an object, and it gets invoked at the meter of object creation. Rules for builder are :

  • Constructor Name should be the same as a class name.
  • A constructor must have no return type.

10) Define Destructor?
A destructor is a method acting which is automatically called when the aim is made of oscilloscope or destroyed. Destructor name is besides like as class name but with the tilde symbol before the identify .
11) What is an Inline function?
An inline function is a proficiency used by the compilers and instructs to insert complete consistency of the serve wherever that function is used in the plan source code .
12) What is a virtual function?
A virtual serve is a penis function of a class, and its functionality can be overridden in its derive course. This function can be implemented by using a keyword called virtual, and it can be given during function contract .
A virtual function can be declared using a nominal ( virtual ) in C++. It can be achieved in C/Python Language by using serve pointers or pointers to function .
13) What is a friend function?
A friend routine is a acquaintance of a class that is allowed to access to Public, private, or protected data in that same class. If the function is defined outside the class can not access such data .
A acquaintance can be declared anywhere in the class declaration, and it can not be affected by access restraint keywords like individual, public, or protected .
14) What is function overloading?
function overload is a regular function, but it is assigned with multiple parameters. It allows the creation of several methods with the lapp name which differ from each early by the type of input and output of the function .

void add(int& a, int& b);

void add(double& a, double& b);

void add(struct bob& a, struct bob& b);

15) What is operator overloading?
operator overload is a function where different operators are applied and depends on the arguments. hustler, -, * can be used to pass through the function, and it has its own precedence to execute
16) What is an abstract class?
An abstract class is a class which can not be instantiated. creation of an object is not potential with an abstract class, but it can be inherited. An abstract course can contain only an Abstract method. Java allows only pilfer method acting in abstract class while other languages allow non-abstract method acting as well .
17) What is a ternary operator?
The three hustler is said to be an operator which takes three arguments. Arguments and results are of different data types, and it depends on the function. The three hustler is besides called a conditional operator .
18) What is the use of finalize method?
Finalize method acting helps to perform cleanup operations on the resources which are not presently used. Finalize method acting is protected, and it is accessible merely through this course or by a derive class .
19) What are the different types of arguments?
A argument is a variable used during the resolution of the function or routine, and arguments are passed to the function body, and it should match with the parameter defined. There are two types of Arguments .

  • Call by Value – Value passed will get modified only inside the function, and it returns the same value whatever it is passed into the function.
  • Call by Reference – Value passed will get modified in both inside and outside the functions and it returns the same or different value.

20) What is the super keyword?
The super keyword is used to invoke the override method, which overrides one of its superclass methods. This keyword allows to access overrule methods and besides to access obscure members of the superclass .
It besides forwards a call from a builder, to a builder in the superclass .
21) What is method overriding?
Method override is a sport that allows a subclass to provide the execution of a method acting that overrides in the main course. It will override the implementation in the superclass by providing the like method name, like argument, and like return character .
22) What is an interface?
An interface is a collection of an abstract method acting. If the class implements an interface, it thereby inherits all the pilfer methods of an interface .
Java uses Interface to implement multiple inheritances .
23) What is exception handling?
An exception is an event that occurs during the execution of a platform. Exceptions can be of any type – Runtime exception, Error exceptions. Those exceptions are adequately handled through exception handling mechanism like judge, catch, and throw keywords .
24) What are tokens?
A compiler recognizes a token, and it can not be broken down into component elements. Keywords, identifiers, constants, string literals, and operators are examples of tokens .
even punctuation characters are besides considered as tokens. exercise : Brackets, Commas, Braces, and Parentheses .
25) What is the main difference between overloading and overriding?
overload is static Binding, whereas Overriding is moral force Binding. Overloading is nothing but the same method acting with different arguments, and it may or may not return the peer value in the same class itself .
Overriding is the same method acting names with the lapp arguments and return types associated with the class and its child classify.

26) What is the main difference between a class and an object?
An object is an exemplify of a class. Objects hold multiple information, but classes don ’ t have any information. definition of properties and functions can be done in class and can be used by the object .
A class can have sub-classes, while an object doesn ’ thymine have sub-objects .
27) What is an abstraction?
abstractedness is a useful feature of speech of OOPS, and it shows only the necessary details to the customer of an object. Meaning, it shows only required details for an object, not the inner constructors, of an object. Example – When you want to switch on the television, it is not necessary to know the inner circuitry/mechanism needed to switch on the television. Whatever is required to switch on television receiver will be shown by using an pilfer class .
28) What are the access modifiers?
access modifiers determine the scope of the method or variables that can be accessed from other respective objects or classes. There are five types of access modifiers, and they are as follows :

  • Private
  • Protected
  • Public
  • Friend
  • Protected Friend

29) What are sealed modifiers?
Sealed modifiers are the access modifiers where the methods can not inherit it. Sealed modifiers can besides be applied to properties, events, and methods. This modifier can not be used to inactive members .
30) How can we call the base method without creating an instance?
Yes, it is possible to call the base method acting without creating an example. And that method acting should be “ Static method. ”
Doing inheritance from that class.-Use Base Keyword from a derive class .
31) What is the difference between new and override?
The modern modifier instructs the compiler to use the new implementation rather of the basal class function. Whereas, Override modifier helps to override the base class serve .
32) What are the various types of constructors?
There are three types of constructors :
– Default Constructor – With no parameters .
– Parametric Constructor – With Parameters. Create a modern exemplify of a class and besides passing arguments simultaneously .
– Copy Constructor – Which creates a new object as a copy of an existing object .
33) What is early and late Binding?
early binding refers to the assignment of values to variables during design prison term, whereas deep bind refers to the assignment of values to variables during streak time .
34) What is ‘this’ pointer?
THIS arrow refers to the stream object of a class. THIS keyword is used as a arrow which differentiates between the current object with the global object. It refers to the current object .

35) What is the difference between structure and a class?
The default access type of a Structure is populace, but class access type is private. A structure is used for grouping data, whereas a class can be used for grouping data and methods. Structures are entirely used for data, and it doesn ’ triiodothyronine require rigid validation, but classes are used to encapsulate and implicit in data, which requires rigorous establishment .
36) What is the default access modifier in a class?
The default access modifier of a class is Internal and the default option access modifier of a class penis is Private .
37) What is a pure virtual function?
A arrant virtual function is a officiate which can be overridden in the derive classify but can not be defined. A virtual routine can be declared as pure by using the operator =0 .
Example –

Virtual void function1() // Virtual, Not pure

Virtual void function2() = 0 //Pure virtual

38) What are all the operators that cannot be overloaded?
Following are the operators that can not be overloaded – .

  1. Scope Resolution (::)
  2. Member Selection (.)
  3. Member selection through a pointer to function (.*)

39) What is dynamic or run time polymorphism?
Dynamic or Run prison term polymorphism is besides known as method acting override in which call to an override serve is resolved during discharge meter, not at the compile time. It means having two or more methods with the same name, same signature but with unlike implementation .
40) Do we require a parameter for constructors?
nobelium, we do not require a parameter for constructors .
41) What is a copy constructor?
This is a limited builder for creating a raw object as a replicate of an existing object. There will always be alone one imitate builder that can be either defined by the user or the system .
42) What does the keyword virtual represented in the method definition?
It means we can override the method acting .
43) Whether static method can use nonstatic members?
False .
44) What are a base class, subclass, and superclass?
The free-base class is the most popularize class, and it is said to be a root class .
A Subclass is a course that inherits from one or more base classes .
The superclass is the parent classify from which another class inherit .
45) What is static and dynamic Binding?
Binding is nothing but the association of a name with the class. static Binding is a constipate in which name can be associated with the class during compilation time, and it is besides called as early Binding .
Dynamic Binding is a oblige in which name can be associated with the class during execution time, and it is besides called as late Binding .
46) How many instances can be created for an abstract class?
Zero instances will be created for an abstract course. In other words, you can not create an case of an Abstract Class .
47) Which keyword can be used for overloading?
hustler keyword is used for overloading .
48) What is the default access specifier in a class definition?
secret entree specifier is used in a classify definition .
49) Which OOPS concept is used as a reuse mechanism?
inheritance is the OOPS concept that can be used as a recycle mechanism .
50) Which OOPS concept exposes only the necessary information to the calling functions?


source :
Category : interview

We will be happy to hear your thoughts

Leave a reply

GauDay Crypto news and market tracking in real time
Enable registration in settings - general