This set of Object Oriented Programming online test focuses on “OOP Basic Concepts”.
1. Which was the first purely object oriented programming language developed?
Explanation: SmallTalk was the first programming language developed which was purely object oriented. It was developed by Alan Kay. OOP concept came into picture in 1970’s.
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
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
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
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
c) Duplicate/Redundant data
d) Efficient Code
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)
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?
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?
d) Small Talk
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
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.
10. When OOP concept did first came into picture?
Explanation: OOP first came into picture in 1970’s by Alan and his team. Later it was used by some programming languages and got implemented successfully, SmallTalk was first language to use pure OOP and followed all rules strictly.
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
Explanation: As Java supports usual declaration of data variables, it is partial implementation of OOP. Because according to rules of OOP, object constructors must be used, even for declaration of variables.
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
Explanation: In C++, it’s not necessary to use classes, and hence codes can be written without using OOP concept. Classes may or may not contain member functions, so it’s not a necessary condition in C++. And, an object can only be declared in a code if its class is defined/included via header file.
13. Which header file is required in C++ to use OOP?
d) OOP can be used without using any header file
Explanation: We need not include any specific header file to use OOP concept in C++, only specific functions used in code need their respective header files to be included or classes should be defined if needed.
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
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.
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
Explanation: Use of this pointer allows an object to call data and methods of itself whenever needed. This helps us call the members of an object recursively, and differentiate the variables of different scopes.
Sanfoundry Global Education & Learning Series – Object Oriented Programming (OOPs).
To practice all areas of Object Oriented Programming for online tests, here is complete set of 1000+ Multiple Choice Questions and Answers.