OBJECT-ORIENTED PROGRAMMING TEST
QUESTIONS AND ANSWERS
What is OOPS? - ANSWER OOPS- Object Oriented Programming system in
which programs are considered as a collection of objects. Each object is nothing
but an instance of a class.
Write basic concepts of OOPS? - ANSWER Abstraction.
Encapsulation.
Inheritance.
Polymorphism.
What is a class? - ANSWER A class is simply an appearance of any kind of
object. It is a blueprint/plan/template that defines details about an object.
What is an object? - ANSWER An object is an instance of a class. It has its
own state, behavior, and identity.
What is Encapsulation? - ANSWER 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.
Levels are Public, Protected, Private, Internal and Protected Internal.
, What is Polymorphism? - ANSWER 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.
What is Inheritance? - ANSWER Inheritance is the concept where one class
shares the structure and behaviour defined in another class. If inheritance
applied on one class is called Single Inheritance, and if it depends on multiple
classes, then it is called multiple Inheritance.
What are manipulators? - ANSWER Manipulators are the functions which can
be used in conjunction with the insertion (<<) and extraction (>>) operators on
an object. Examples are endl and setw.
Define a constructor? - ANSWER A constructor is a method used to initialize
the state of an object, and it gets invoked at the time of object creation. Rules
for constructor are:
- The name of Constructor should be the same as that of class name.
- A constructor does not have any return type.
Define Destructor? - ANSWER A destructor is a method which is
automatically called when the object is made of scope or destroyed. Destructor
name is also the same as class name but with the tilde symbol before the name.
What is an Inline function? - ANSWER An inline function is a technique used
by the compilers and instructs to insert complete body of the function wherever
that function is used in the program source code.
QUESTIONS AND ANSWERS
What is OOPS? - ANSWER OOPS- Object Oriented Programming system in
which programs are considered as a collection of objects. Each object is nothing
but an instance of a class.
Write basic concepts of OOPS? - ANSWER Abstraction.
Encapsulation.
Inheritance.
Polymorphism.
What is a class? - ANSWER A class is simply an appearance of any kind of
object. It is a blueprint/plan/template that defines details about an object.
What is an object? - ANSWER An object is an instance of a class. It has its
own state, behavior, and identity.
What is Encapsulation? - ANSWER 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.
Levels are Public, Protected, Private, Internal and Protected Internal.
, What is Polymorphism? - ANSWER 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.
What is Inheritance? - ANSWER Inheritance is the concept where one class
shares the structure and behaviour defined in another class. If inheritance
applied on one class is called Single Inheritance, and if it depends on multiple
classes, then it is called multiple Inheritance.
What are manipulators? - ANSWER Manipulators are the functions which can
be used in conjunction with the insertion (<<) and extraction (>>) operators on
an object. Examples are endl and setw.
Define a constructor? - ANSWER A constructor is a method used to initialize
the state of an object, and it gets invoked at the time of object creation. Rules
for constructor are:
- The name of Constructor should be the same as that of class name.
- A constructor does not have any return type.
Define Destructor? - ANSWER A destructor is a method which is
automatically called when the object is made of scope or destroyed. Destructor
name is also the same as class name but with the tilde symbol before the name.
What is an Inline function? - ANSWER An inline function is a technique used
by the compilers and instructs to insert complete body of the function wherever
that function is used in the program source code.