Object Oriented Programming MCQ (Multiple Choice Questions) - SchoolingAxis

Object Oriented Programming MCQ (Multiple Choice Questions)

 Que- Which among the following is the main characteristic of class? 

a. Inheritance 

b. Encapsulation 

c. Polymorphism 

d. Object creation 


Ans- Encapsulation  


Que- To group all the brands of cars, what should be used? 

a. Class 

b. Structure 

c. Function 

d. Object 


Ans- Class  


Que- If a class have two data members and two functions to add those two numbers and to subtract them, which among the following is most efficient if the programmer wants to implement multiplication too? 

a. Define a public function which multiplies two numbers 

b. Define a public function that returns values of two data members 

c. Define a private function which multiplies two numbers 

d. Define a private function that returns values of two data members 


Ans- Define a public function that returns values of two data members  


Que- If a database have to be maintained using OOP, to store the details of each employee in a company, which would be the best choice among the following? 

a. Define a class to store details of each employee 

b. Define a structure to store details of each employee 

c. Define separate variable for each detail 

d. Define a generic type to store string and number details 


Ans- Define a class to store details of each employee  


Que- Which class represents the most abstracted information? 

a. Nested 

b. Derived 

c. Enclosed 

d. Base 


Ans- Base  


Que- Which among the following is an advantage of using classes over structures of C? 

a. Functions are restricted 

b. Functions can't be defined 

c. Functions can also be encapsulated 

d. Functions can have more security 


Ans- Functions can also be encapsulated  


Que- Which among the follow is a feature of class? 

a. Object orientation 

b. Procedure orientation 

c. Both object and procedure orientation 

d. Neither object nor procedure orientation 


Ans- Object orientation  


Que- Class is _____________ of an object. 

a. Basic function definition 

b. Detailed description with values 

c. Blueprint 

d. Set of constant values 


Ans- Blueprint  


Que- In which case the classes can be used to make more efficient program? 

a. To define a function that is called frequently in a program 

b. To structure data that is most similar 

c. To group the most similar data and operations 

d. To define a blueprint that shows memory location of data 


Ans- To group the most similar data and operations  


Que- What is the use of inbuilt classes? 

a. Provide predefined data 

b. Provide predefined functions 

c. Provide predefined data and functions 

d. Provide predeclared data to be overridden 


Ans- Provide predefined data and functions  


Que- Which feature is exhibited by the inbuilt classes? 

a. Code reusability 

b. Code efficiency 

c. Code readability 

d. Code reusability, efficiency and readability 


Ans- Code reusability, efficiency and readability  


Que- Why do we use user defined classes? 

a. To design a user intended code 

b. To model real world objects 

c. To design the interfaces 

d. To model the functions 


Ans- To model real world objects  


Que- Why do classes use accessor methods? 

a. To make public data accessible to client 

b. To make public data private to client 

c. To make private data public for whole program 

d. To make private data accessible to the client 


Ans- To make private data accessible to the client  


Que- Why do classes use mutator methods? 

a. Allows client to modify the program 

b. Allows client to modify/write the private members 

c. Allows servers to access all the private data 

d. Allows servers to access only protected members 


Ans- Allows client to modify/write the private members  


Que- Which among the following is the most abstract form of class? 

a. Cars 

b. BMW cars 

c. Big cars 

d. Small cars 


Ans- Cars  


Que- Which among the following best describes the Inheritance? 

a. Copying the code already written 

b. Using the code already written once 

c. Using already defined functions in programming language 

d. Using the data and functions into derived segment 


Ans- Using the data and functions into derived segment  


Que- How many basic types of inheritance are provided as OOP feature? 

a. 4 

b. 3 

c. 2 

d. 1 


Ans- 4  


Que- Which among the following best defines single level inheritance? 

a. A class inheriting a derived class 

b. A class inheriting a base class 

c. A class inheriting a nested class 

d. A class which gets inherited by 2 classes 


Ans- A class inheriting a base class  


Que- Which among the following is correct for multiple inheritance? 

a. class student{public: int marks;}s; class stream{int total;}; class topper:public student, public stream{ }; 

b. class student{int marks;}; class stream{ }; class topper: public student{ }; 

c. class student{int marks;}; class stream:public student{ }; 

d. class student{ }; class stream{ }; class topper{ }; 


Ans- class student{public: int marks;}s; class stream{int total;}; class topper:public student, public stream{ };  


Que- Which programming language doesn't support multiple inheritance? 

a. C++ and Java 

b. C and C++ 

c. Java and SmallTalk 

d. Java 


Ans- Java  


Que- Which among the following is correct for hierarchical inheritance? 

a. Two base classes can be used to be derived into one single class 

b. Two or more classes can be derived into one class 

c. One base class can be derived into other two derived classes or more 

d. One base class can be derived into only 2 classes 


Ans- One base class can be derived into other two derived classes or more  


Que- Which is the correct syntax of inheritance? 

a. class derived_classname : base_classname{ /*define class body*/ }; 

b. class base_classname : derived_classname{ /*define class body*/ }; 

c. class derived_classname : access base_classname{ /*define class body*/ }; 

d. class base_classname :access derived_classname{ /*define class body*/ }; 


Ans- class derived_classname : access base_classname{ /*define class body*/ };  


Que- Which type of inheritance leads to diamond problem? 

a. Single level 

b. Multi-level 

c. Multiple 

d. Hierarchical 


Ans- Multiple  


Que- Which access type data gets derived as private member in derived class: 

a. Private 

b. Public 

c. Protected 

d. Protected and Private 


Ans- Private  


Que- If a base class is inherited in protected access mode then which among the following is true? 

a. Public and Protected members of base class becomes protected members of derived class 

b. Only protected members become protected members of derived class 

c. Private, Protected and Public all members of base, become private of derived class 

d. Only private members of base, become private of derived class 


Ans- Public and Protected members of base class becomes protected members of derived class  


Que- Members which are not intended to be inherited are declared as: 

a. Public members 

b. Protected members 

c. Private members 

d. Private or Protected members 


Ans- Private members  


Que- While inheriting a class, if no access mode is specified, then which among the following is true? (in C++) 

a. It gets inherited publicly by default 

b. It gets inherited protected by default 

c. It gets inherited privately by default 

d. It is not possible 


Ans- It gets inherited privately by default  


Que- If a derived class object is created, which constructor is called first? 

a. Base class constructor 

b. Derived class constructor 

c. Depends on how we call the object 

d. Not possible 


Ans- Base class constructor  


Que- How can you make the private members inheritable? 

a. By making their visibility mode as public only 

b. By making their visibility mode as protected only 

c. By making their visibility mode as private in derived class 

d. It can be done both by making the visibility mode public or protected 


Ans- It can be done both by making the visibility mode public or protected  


Que- How many types of inheritance are possible in C++? 

a. 2 

b. 3 

c. 4 

d. 5 


Ans- 5  


Que- Which among the following is true? 

a. Java supports all types of inheritance 

b. Java supports multiple inheritance 

c. Java doesn't support multiple inheritance 

d. Java doesn't support inheritance 


Ans- Java doesn't support multiple inheritance  


Que- Which among the following best describes multiple inheritance? 

a. Two classes being parent of any other classes 

b. Three classes being parent of other classes 

c. More than one class being parent of other child classes 

d. More than one class being parent of single child 


Ans- More than one class being parent of single child  


Que- How many types of inheritance can be used at a time in single program? 

a. Any two types 

b. Any three types 

c. Any 4 types 

d. Any type, any number of times 


Ans- Any type, any number of times  


Que- Which type of inheritance results in diamond problem? 

a. Single level 

b. Hybrid 

c. Hierarchical 

d. Multilevel 


Ans- Hybrid  


Que- If 6 classes uses single level inheritance with pair classes (3 pairs), which inheritance will this be called? 

a. Single 

b. Multiple 

c. Hierarchical 

d. Multilevel 


Ans- Single  


Que- Which among the following is false? 

a. If one class inherits the inherited class in single level inheritance, it is multi-level inheritance 

b. Hybrid inheritance always contains multiple inheritance 

c. Hierarchical inheritance involves inheriting same class into more than one classes 

d. Hybrid inheritance can involve any types of inheritance together 


Ans- Hybrid inheritance always contains multiple inheritance  


Que- If class A has two nested classes B and C. Class D has one nested class E, and have inherited class A. If E inherits B and C, then: 

a. It shows multiple inheritance 

b. It shows hierarchical inheritance 

c. It shows multiple inheritance 

d. Multiple inheritance among nested classes, and single level for enclosing classes 


Ans- Multiple inheritance among nested classes, and single level for enclosing classes  


Que- Which type of inheritance cannot involve private inheritance? 

a. Single level 

b. Multiple 

c. Hybrid 

d. All types can have private inheritance 


Ans- All types can have private inheritance  


Que- How many classes can be inherited by a single class in multiple inheritance (C++)? 

a. Only 2 

b. Only 27 

c. Only 1024 

d. Any number of classes can be inherited 


Ans- Any number of classes can be inherited  


Que- How many classes can be inherited by a single class in java? 

a. Only 1 

b. Only 27 

c. Only 255 

d. Only 1024 


Ans- Only 1  


Que- If multi-level inheritance is used, First class B inherits class A, then C inherits B and so on. Till how many classes can this go on? 

a. Only till class C 

b. Only till class J 

c. Only till class Z 

d. There is no limit 


Ans- There is no limit  


Que- Which among the following defines single level inheritance? 

a. One base class derives another class 

b. One derived class inherits from one base class 

c. One base class inherits from one derived class 

d. One derived class derives from another derived class 


Ans- One derived class inherits from one base class  


Que- If class A and class B are derived from class C and class D, then ________________ 

a. Those are 2 pairs of single inheritance 

b. That is multilevel inheritance 

c. Those is enclosing class 

d. Those are all independent classes 


Ans- Those are 2 pairs of single inheritance  


Que- If single inheritance is used, program will contain ________________ 

a. At least 2 classes 

b. At most 2 classes 

c. Exactly 2 classes 

d. At most 4 classes 


Ans- At least 2 classes  


Que- Single level inheritance supports _____________ inheritance. 

a. Runtime 

b. Compile time 

c. Multiple inheritance 

d. Language independency 


Ans- Runtime  


Que- If single level inheritance is used and an abstract class is created with some undefined functions, can its derived class also skip some definitions? 

a. Yes, always possible 

b. Yes, possible if only one undefined function 

c. No, at least 2 undefined functions must be there 

d. No, the derived class must implement those methods 


Ans- No, the derived class must implement those methods  


Que- Which among the following is false for single level inheritance? 

a. There can be more than 2 classes in program to implement single inheritance 

b. There can be exactly 2 classes to implement single inheritance in a program 

c. There can be more than 2 independent classes involved in single inheritance 

d. The derived class must implement all the abstract method if single inheritance is used 


Ans- There can be more than 2 independent classes involved in single inheritance  


Que- Which concept will result in derived class with more features (consider maximum 3 classes)? 

a. Single inheritance 

b. Multiple inheritance 

c. Multilevel inheritance 

d. Hierarchical inheritance 


Ans- Multiple inheritance  


Que- Single level inheritance is safer than _____________ 

a. Multiple inheritance 

b. Interfaces 

c. Implementations 

d. Extensions 


Ans- Multiple inheritance  


Que- Which language doesn't support single level inheritance? 

a. Java 

b. C++ 

c. Kotlin 

d. All languages support it 


Ans- All languages support it  


Que- Single level inheritance will be best for___________ 

a. Inheriting a class which performs all the calculations 

b. Inheriting a class which can print all the calculation results 

c. Inheriting a class which can perform and print all calculations 

d. Inheriting all the classes for different calculations 


Ans- Inheriting a class which can print all the calculation results  


Que- Which constructor will be called first from the classes involved in single inheritance from object of derived class? 

a. Base class constructor 

b. Derived class constructor 

c. Both class constructors at a time 

d. Runtime error 


Ans- Base class constructor  


Que- If base class contains 2 nested classes, will it be possible to implement single level inheritance? 

a. Yes, always 

b. Yes, only if derived class also have nested classes 

c. No, it will use more than 2 classes which is wrong 

d. No, never 


Ans- Yes, always  


Que- Which among the following best defines multilevel inheritance? 

a. A class derived from another derived class 

b. Classes being derived from other derived classes 

c. Continuing single level inheritance 

d. Class which have more than one parent 


Ans- Classes being derived from other derived classes  


Que- If there are 5 classes, E is derived from D, D from C, C from B and B from A. Which class constructor will be called first if the object of E or D is created? 

a. A 

b. B 

c. C 

d. A and B 


Ans- A  


Que- If there are 3 classes. Class C is derived from class B and B is derived from A, Which class destructor will be called at last if object of C is destroye

d. 

a. A 

b. B 

c. C 

d. All together 


Ans- A  


Que- Which Class is having highest degree of abstraction in multilevel inheritance of 5 levels? 

a. Class at 1st level 

b. Class 2nd last level 

c. Class at 5th level 

d. All with same abstraction 


Ans- Class at 1st level  


Que- If all the classes use private inheritance in multilevel inheritance then ______________ 

a. It will not be called multilevel inheritance 

b. Each class can access only non-private members of its parent 

c. Each subsequent class can access all members of previous level parent classes 

d. None of the members will be available to any other class 


Ans- Each class can access only non-private members of its parent  


Que- Multilevel inheritance allows _________________ in the program. 

a. Only 7 levels of inheritance 

b. At least 7 levels of inheritance 

c. At most 16 levels of inheritance 

d. As many levels of inheritance as required 


Ans- As many levels of inheritance as required  


Que- What is minimum number of levels for a implementing multilevel inheritance? 

a. 1 

b. 2 

c. 3 

d. 4 


Ans- 3  


Que- In multilevel inheritance one class inherits _______________ 

a. Only one class 

b. More than one class 

c. At least one class 

d. As many classes as required 


Ans- Only one class  


Que- Can abstract classes be used in multilevel inheritance? 

a. Yes, always 

b. Yes, only one abstract class 

c. No, abstract class doesn't have constructors 

d. No, never 


Ans- Yes, always  


Que- How many abstract classes can be used in multilevel inheritance? 

a. Only 1 

b. Only 2 

c. At least one less than number of levels 

d. Can't be used 


Ans- At least one less than number of levels  


Que- If all the classes used parameterized constructors and no default constructor then, ___________ 

a. The object of lower level classes can't be created 

b. Object of lower level classes must call parent class constructors explicitly 

c. Object of lower level classes must define all the default constructors 

d. Only object of first class can be created, which is first parent 


Ans- Object of lower level classes must call parent class constructors explicitly  


Que- In multilevel inheritance, which is the most significant feature of OOP used? 

a. Code readability 

b. Flexibility 

c. Code reusability 

d. Code efficiency 


Ans- Code reusability  


Que- Is it compulsory for all the classes in multilevel inheritance to have constructors defined explicitly if only last derived class object is created? 

a. Yes, always 

b. Yes, to initialize the members 

c. No, it not necessary 

d. No, Constructor must not be defined 


Ans- No, it not necessary  


Que- Multiple inheritance is ____________________ 

a. When a class is derived from another class 

b. When a class is derived from two or more classes 

c. When a class is derived from other two derived classes 

d. When a class is derived from exactly one class 


Ans- When a class is derived from two or more classes  


Que- Which problem arises due to multiple inheritance, if hierarchical inheritance is used previously for its base classes? 

a. Diamond 

b. Circle 

c. Triangle 

d. Loop 


Ans- Diamond  


Que- How many classes should a program contain to implement the multiple inheritance? 

a. Only 1 

b. At least 1 

c. At least 3 

d. Exactly 3 


Ans- At least 3  


Previous Post Next Post