Object Oriented
Programming using C++
OOPs Basic Concepts
Object-oriented programming – As the name suggests uses objects in programming. Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism, etc in programming. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of the code can access this data except that function.
1. Which was the first purely
object-oriented programming language developed?
a) Java
b) C++
c) SmallTalk
d) Kotlin
2. 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
Explanation: A class is Blueprint of an object which describes/ shows all the
functions and data that are provided by an object of a specific class. It can’t
be called as parent or instance of an object. Class in general describes all
the properties of an object.
3. 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.
4. 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.
5. 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
6. Pure OOP can be implemented
without using class in a program. (True or False)
a) True
b) False
Answer:
b
Explanation: It’s false because for a program to be pure OO, everything must be
written inside classes. If this rule is violated, the program can’t be labelled
as purely OO.
7. 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
8. 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.
9. 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
View[P9] Answer
10. When OOP concept did first come
into picture?
a) 1970’s
b) 1980’s
c) 1993
d) 1995
View
Answer[P10]
11. Why Java is Partially OOP
language?
a) It supports usual declaration of primitive data types
b) It doesn’t support all types of inheritance
c) It allows code to be written outside classes
d) It does not support pointers
View[P11] Answer
12. Which concept of OOP is false
for C++?
a) Code can be written without using classes
b) Code must contain at least one class
c) A class must have member functions
d) At least one object should be declared in code
View
Answer[P12]
13. Which header file is required in
C++ to use OOP?
a) iostream.h
b) stdio.h
c) stdlib.h
d) OOP can be used without using any header file
View[P13] Answer
14. Which of the two features match
each other?
a) Inheritance and Encapsulation
b) Encapsulation and Polymorphism
c) Encapsulation and Abstraction
d) Abstraction and Polymorphism
View[P14] Answer
15. Which feature allows open
recursion, among the following?
a) Use of this pointer
b) Use of pointers
c) Use of pass by value
d) Use of parameterized constructor
View[P15] Answer