OOP Concepts
OOP Concepts
Encapsulation is placing the data and the functions that work on that data in the
same place. While working with procedural languages, it is not always clear which
functions work on which variables but object-oriented programming provides you
framework to place the data and the relevant functions together in the same object.
Abstraction
Abstraction refers to showing only the essential features of the application and hiding
the details. In C++, classes can provide methods to the outside world to access & use
the data variables, keeping the variables hidden from direct access, or classes can even
declare everything accessible to everyone, or maybe just to the classes inheriting it.
This can be done using access specifiers.
Abstraction is a process of hiding the implementation details from the user, only the
functionality will be provided to the user. In other words, the user will have the
information on what the object does instead of how it does it.
In Java, abstraction is achieved using Abstract classes and interfaces.
Answer: c
Which of the following best defines a class?
a) Parent of an object
b) Instance of an object
c) Blueprint of an object
d) Scope of an object
Answer: c
class is blue print or template for an object or structure of object
Who invented OOP?
a) Alan Kay
b) Andrea Ferro
c) Dennis Ritchie
d) Adele Goldberg
Answer: a
Explanation: Alan Kay invented OOP, Andrea Ferro was a part of
SmallTalk Development.
Dennis invented C++ and Adele Goldberg was in team to develop
SmallTalk but Alan actually had got rewarded for OOP.
What is the additional feature in classes that was not in structures?
a) Data members
b) Member functions
c) Static data allowed
d) Public access specifier
Answer: b
Explanation: Member functions are allowed inside a class but were
not present in structure concept. Data members, static data and
public access specifiers were present in structures too.
Which is not feature of OOP in general definitions?
a) Code reusability
b) Modularity
c) Duplicate/Redundant data
d) Efficient Code
Answer: c
Explanation: Duplicate/Redundant data is dependent on
programmer and hence can’t be guaranteed by OOP. Code
reusability is done using inheritance. Modularity is supported by
using different code files and classes. Codes are more efficient
because of features of OOP.
Which Feature of OOP illustrated the code reusability?
a) Polymorphism
b) Abstraction
c) Encapsulation
d) Inheritance
Answer: d
Explanation: Using inheritance we can reuse the code already
written and also can avoid creation of many new functions or
variables, as that can be done one time and be reused, using
classes.
Which language does not support all 4 types of inheritance?
a) C++
b) Java
c) Kotlin
d) Small Talk
Answer: b
Explanation: Java doesn’t support all 4 types of inheritance.
It doesn’t support multiple inheritance. But the multiple
inheritance can be implemented using interfaces in Java.
How many classes can be defined in a single program?
a) Only 1
b) Only 100
c) Only 999
d) As many as you want
Answer: d
Explanation: Any number of classes can be defined inside a
program, provided that their names are different. In java, if
public class is present then it must have the same name as
that of file.
Which of the two features match each other?
a) Inheritance and Encapsulation
b) Encapsulation and Polymorphism
c) Encapsulation and Abstraction
d) Abstraction and Polymorphism
Answer: c
Explanation: Encapsulation and Abstraction are similar features.
Encapsulation is actually binding all the properties in a single class
or we can say hiding all the features of object inside a class. And
Abstraction is hiding unwanted data (for user) and showing only
the data required by the user of program.
Which of following is shared structure of a set of similar
objects
Encapsulation
A Class
Inheritance
None of Above
A. Data hiding
B. Dynamic Typing
C. Dynamic binding
D. Dynamic loading
Answer: Option C