50+ OOP Interview Questions
50+ OOP Interview Questions
1) What is OOPS?
OOPS is abbreviated as Object Oriented Programming system in which programs
are considered as a collection of objects. Each object is nothing but an instance
of a class.
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 instance of a class. It has its own state, behavior, and identity.
5) What is Encapsulation?
Encapsulation is an attribute of an object, and it contains all data which is hidden.
That hidden data can be restricted to the members of that class.
6) What is Polymorphism?
Polymorphism is nothing but assigning behavior or value in a subclass to
something that was already declared in the main class. 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 class. If Inheritance applied to one class is called Single
Inheritance, and if it depends on multiple classes, then it is called multiple
Inheritance.
Example
void add(int& a, int& b);
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.
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 also be applied to properties, events, and methods. This
modifier cannot be used to static members.
Doing Inheritance from that class.-Use Base Keyword from a derived class.
Example –
Virtual void function1() // Virtual, Not pure
The superclass is the parent class from which another class inherits.
Dynamic Binding is a binding in which name can be associated with the class
during execution time, and it is also called as Late Binding.
Thanks