OOPs stands for “Object-Oriented Programming System”, OOPs is an approach/paradigm based on the concept of “objects” for developing software programming. It uses classes and objects to overcome flaws in the procedural approach to programs such as reusability and maintainability.
OOPs MCQs: This section contains multiple-choice questions and answers on the OOPs. It will help the students to test their skills and prepare well for their exams.
List of OOPs MCQs
1. ____ is considered to be a partitioned area of computer memory that stores and set of operations that can access the data.
- Classes
- Objects
- Variables
- Functions
Answer: B) Objects
Explanation:
An object is considered to be a partitioned area of computer memory that stores and set of operations that can access the data.
2. When a program is executed, the ____ interacted by sending a message to one another.
- Objects
- Classes
- Operating system
- Memory
Answer: A) Objects
Explanation:
When a program is executed, the objects interact by sending a message to one another. For example, if “customer” and “account” are two objects in a program, then the customer object may send a message to the account object requesting the back balance.
3. Objects are the variables of the type ____?
- String
- Boolean
- Class
- All data types can be included
Answer: C) Class
Explanation:
Objects are the variables of the type Class. Once the class has been defined, we can create any number of objects belonging to that class.
4. What is the most striking feature of class?
- Data encapsulation
- Collection of objects of similar type
- Inheritance
- All of the above
Answer: A) Data encapsulation
Explanation:
Data encapsulation is the most striking feature of the class.
5. Why classes are known as abstract data types (ADT)?
- Because classes are user-defined data types
- Because it supports the theory of hierarchical classification
- Because it allows dynamic binding
- Because it uses the concept of data abstraction
Answer: D) Because it uses the concept of data abstraction
Explanation:
Since classes use the concept of data abstraction therefore they are known as Abstract data types (ADT).
6. Which is not true about the object-oriented approach?
- Emphasis is on data rather than procedure
- Data is hidden and cannot be accessed by external functions
- Objects communicate through functions
- It supports abstract data but not the class
Answer: D) It supports abstract data but not the class
Explanation:
Object-oriented approach supports both abstract data and class, which provide polymorphism and inheritance.
7. Which language among the following support an object-oriented approach?
- Modula-3
- Ada 95
- Modula-2
- Both A and B
Answer: D) Both A and B
Explanation:
Modula-3 and Ada 95 are the languages that support an object-oriented approach.
8. Which language among the following support an object-based approach?
- Modula-3
- 83 Ada
- Modula-2
- Ada 95
- Both A and B
Answer: E) Both A and B
Explanation:
Modula-3 and 83 Ada are the languages that support an object-based approach.
9. Which concept is not supported by object-based programming languages?
- Inheritance
- Dynamic binding
- Only A
- Both A and B
Answer: D) Both A and B
Explanation:
Inheritance and Dynamic binding are the concepts that object-based programming languages do not support.
10. Which approach among the following supports all the features along with inheritance and dynamic binding?
- Object-based approach
- Object-oriented approach
Answer: B) Object-oriented approach
Explanation:
Object-oriented approach supports all the features along with inheritance and dynamic binding.
11. What is procedure-oriented Language?
- A procedure-oriented Language is a language that incorporates all object-oriented programming features
- A procedure-oriented Language is a language that supports encapsulation and object identity
- A procedure-oriented Language is a language that consists of writing a list of instructions
- A procedure-oriented Language is a language that does not support Inheritance and Dynamic binding
Answer: C) A procedure-oriented Language is a language that consists of writing a list of instructions
Explanation:
A procedure-oriented Language is a language that consists of writing a list of instructions for the computer.
12. Which one of the following is the demerit of procedure-oriented languages?
- A procedure-oriented language does not model real-world problems
- In procedure-oriented Language message parsing is difficult
- A procedure-oriented Language works slowly
- In procedure-oriented Language, it is difficult to apply the inheritance concept
Answer: A) A procedure-oriented language does not model real-world problems
Explanation:
A procedure-oriented language does not model real-world problems because functions are action-oriented.
13. Which one of the following states the correct difference between object-oriented programming and object-based programming?
- A procedure-oriented language emphasizes data rather than procedure.
An object-oriented language emphasizes doing things or algorithms. - A procedure-oriented language emphasizes doing things or algorithms.
An object-oriented language emphasizes data rather than procedure. - In procedure-oriented programs are decomposed into functions.
In an object-oriented language, large programs are decomposed into functions. - In procedure-oriented language, large programs are decomposed into functions
In an object-oriented language, programs are decomposed into functions. - Both (a) and (b)
- Both (b) and (d)
Answer: F) Both (b) and (d)
Explanation:
A Procedure-oriented language emphasizes doing things or algorithms and object-oriented language emphasizes data rather than procedure.
In procedure-oriented language, large programs are decomposed into functions and in an object-oriented language, programs are decomposed into functions.
14. Procedure-oriented languages follow which approach?
- Top-down approach
- Bottom-up approach
Answer: A) Top-down approach
Explanation:
A procedure-oriented language follows a Top-down approach whereas object-oriented programming languages follow a bottom-up approach.
15. Object-oriented languages follow which approach?
- Top-down approach
- Bottom-up approach
Answer: B) Bottom-up approach
Explanation:
A procedure-oriented language follows a Top-down approach whereas object-oriented programming languages follow a bottom-up approach.
16. Which feature’s behavior of OOP depends upon the types of data used in the operation.
- Inheritance
- Polymorphism
- Abstraction
- Encapsulation
Answer: B) Polymorphism
Explanation:
Polymorphism behavior depends upon the types of data used in the operation. For example, if we have two int type data and we add them, then the result produced will be also of the type int.
17. Which features of OOP are extensively used in implementing inheritance?
- Dynamic binding
- Abstraction
- Operator overloading
- Polymorphism
Answer: D) Polymorphism
Explanation:
Polymorphism means having many forms and it can be used in the same manner with different actions. Therefore it is extensively used in implementing inheritance.
18. Which language does not follow the concept of OOP?
- FORTAN
- RUBY
- JADE
- SCALA
Answer: A) FORTAN
Explanation:
FORTAN, ALGOL, C, etc. are some of the programming languages which do not follow the concept of OOP.
19. Which functions are declared inside a class have to be defined separately outside the class?
- Static functions
- Const functions
- Inline functions
- Member functions
Answer: D) Member functions
Explanation:
Member functions declared inside a class have to be defined separately outside the class. They are much like normal functions.
20. The subroutines contained in an object are called _____ methods.
- Class Methods
- Static Methods
- Instance Methods
- Interface Methods
Answer: C) Instance Methods
Explanation:
The subroutines contained in an object are called instance methods.
21. Which function incorporates a membership ‘identity label’ in the header?
- Member functions
- Normal functions
- Inline functions
- Constant functions
Answer: A) Member functions
Explanation:
A member function incorporates a membership ‘identity label’ in the header. This ‘label’ refers to which class the function belongs to.
22. A non-member function cannot access which data of the class?
- Private data
- Public data
- Protected data
- All of the above
Answer: A) Private data
Explanation:
A member function can access private data of the class but a non-member function cannot do that.
23. An object cannot invoke a private function using the dot operator?
- True
- False
Answer: A) True
Explanation:
An object cannot invoke a private function using the dot operator as it does not have access.
24. ____ member variables are initialized to zero when the first object of its class is created?
- Static
- Local
- Global
- External
Answer: A) Static
Explanation:
Static member variables are initialized to zero when the first object of its class is created. NO other alternative is provided.
25. A static member function can be called using the ____ name.
- Class name
- Object name
Answer: A) Class name
Explanation:
Static member function can be called using the class name (instead of an object name).
Example:
class-name::function-name
26. How many types of abstractions are there in an object-oriented programming language?
- 2 types
- 3 types
- 4 types
- None
Answer: C) 4 types
Explanation:
There are 4 types of abstraction in an object-oriented programming language. They are as follows: Entity abstraction, Action abstraction, Virtual Machine Abstraction, and coincidental Abstraction.
27. An object that represents a useful model of a problem domain is which type of abstraction?
- Action Abstraction
- Virtual Machine Abstraction
- Coincidental Abstraction
- Entity Abstraction
Answer: D) Entity Abstraction
Explanation:
Entity Abstraction is an object that represents a useful model of a problem domain or solution-domain entity.
28. An object that provides a general set of operations, all of which perform the same kind of function is which type of abstraction?
- Action Abstraction
- Virtual Machine Abstraction
- Coincidental Abstraction
- Entity Abstraction
Answer: A) Action Abstraction
Explanation:
Action Abstraction is an object that provides a general set of operations, all of which perform the same kind of function.
29. An object that groups together operations that are all used by some superior level of control or operations that all use some junior-level set of operations is which type of abstraction?
- Action Abstraction
- Virtual Machine Abstraction
- Coincidental Abstraction
- Entity Abstraction
Answer: B) Virtual Machine Abstraction
Explanation:
Virtual Machine Abstraction is an object that groups together operations that are all used by some superior level of control or operations that all use some junior-level set of operations.
30. An object that packages a set of operations that have no relations to each other is which type of abstraction?
- Action Abstraction
- Virtual Machine Abstraction
- Coincidental Abstraction
- Entity Abstraction
Answer: C) Coincidental Abstraction
Explanation:
A coincidental Abstraction is an object that packages a set of operations that have no relations to each other.
31. ____ is the process of compartmentalizing the elements of an abstraction that contribute to its structure and behavior?
- Encapsulation
- Abstraction
- Classes
- Inheritance
Answer: A) Encapsulation
Explanation:
Encapsulation is the process of compartmentalizing the elements of an abstraction that contribute to its structure and behavior.
32. ____ is the property that distinguishes an active object from one that is not active?
- Typing
- Concurrency
- Hierarchy
- Persistence
Answer: B) Concurrency
Explanation:
Concurrency is the property that distinguishes an active object from one that is not active.
33. ____ is the property of an object through which its existence transcends time?
- Object
- Concurrency
- Hierarchy
- Persistence
Answer: D) Persistence
Explanation:
Persistence is the property of an object through which its existence transcends time (i.e. the object exists after its creator ceases to exist).
34. What are manipulators?
- Manipulators are used to specify a character that is used to fill the unused portion of the field
- Manipulators are used to clear the flags specified
- Manipulators are special functions that can be included in the I/O statements to alter the format parameters of a stream
- Manipulators contain large numbers of member functions
Answer: C) Manipulators are special functions that can be included in the I/O statements to alter the format parameters of a stream
Explanation:
Manipulators are special functions that can be included in the I/O statements to alter the format parameters of a stream. We use iomanip to access manipulators.
35. To access manipulators the file ____ should be included in the program.
- iomanip
- ios
- #include
- None
Answer: A) iomanip
Explanation:
We use iomanip to access manipulators.
36. A _____ is a mechanism for converting values of various types into a sequence of characters.
- istream
- ios
- ostream
- iostream
Answer: C) ostream
Explanation:
A ostream is a mechanism for converting values of various types into a sequence of characters. It mainly handles output.
37. What is ios stream class?
- ios stream class contains a pointer to a buffer object
- ios stream class inherits the properties of ios
- ios stream contains overloaded insertion operator<<
- ios stream contains overloaded extraction operator>>
Answer: A) ios stream class contains a pointer to a buffer object
Explanation:
ios stream class contains a pointer to a buffer object, also it contains basic functionalities.
38. What is istream stream class?
- ios stream class inherits the properties of ios.
- ios stream contains overloaded extraction operator>>.
- Only A
- Only B
- Both A and B
Answer: E) Both A and B
Explanation:
istream stream class inherits the properties of ios and also it contains an overloaded extraction operator >>.
39. What is iostream stream class?
- iostream class inherits the properties of ios.
- iosstream class inherits the properties of istream and ostream.
- Only A
- Only B
- Both A and B
Answer: D) Only B
Explanation:
iostream class inherits the properties of istream and ostream.
40. A _____ object is visible throughout a program module.
- Static objects
- Dynamic objects
- External objects
- Automatic objects
Answer: C) External objects
Explanation:
An object which is visible throughout a program module is called an External object. Also known as Global objects.
41. A _____ object which exists for a particular period.
- Static objects
- Dynamic objects
- External objects
- Automatic objects
Answer: D) Automatic objects
Explanation:
Object which exists for a particular period is called Automatic objects, also known as local objects.
42. A _____ object is an object which has the scope of an automatic object but the lifetime of an external object.
- Static objects
- Dynamic objects
- External objects
- Automatic objects
Answer: A) Static objects
Explanation:
A Static object is an object which has the scope of an automatic object but the lifetime of an external object.
43. A _____ object gets its memory allocated at runtime.
- Static objects
- Dynamic objects
Answer: B) Dynamic objects
Explanation:
A dynamic object gets its memory allocated at runtime.
44. How many types of object diagrams are there?
- 2 types
- 3 types
- 4 types
- None
Answer: A) 2 types
Explanation:
There are 2 types of object diagrams: Class diagrams and instance diagrams.
45. A ____ diagram is a schema or pattern for describing many possible instances of data.
- Class diagram
- Instance diagram
Answer: A) Class diagram
Explanation:
A Class diagram is a schema or pattern for describing many possible instances of data.
46. A ____ diagram describes how a particular set of objects relate to each other.
- Class diagram
- Instance diagram
Answer: B) Instance diagram
Explanation:
An Instance diagram describes how a particular set of objects relate to each other.
47. What is a parameterized class?
- A parameterized class is a class that denotes a family of classes whose structure and behavior are defined independently of its formal class parameter
- A parameterized class is a class that uses the concept of a Meta class
- A parameterized class is a class of a class
Answer: A) A parameterized class is a class that denotes a family of classes whose structure and behavior are defined independently of its formal class parameter
Explanation:
A parameterized class is a class that denotes a family of classes whose structure and behavior are defined independently of its formal class parameter.
48. Which of the following defines a Meta class?
- A Meta class is a class that may not itself have any instances.
- A Meta class is a class of a class.
- Meta classes are classes that are different than plain classes.
- All of the above
Answer: D) All of the above
Explanation:
A Meta class is a class of a class that may not itself have any instances and are different than plain classes.
49. Under which pillar of OOPS do base class and derived class relationships come?
- Abstraction
- Encapsulation
- Inheritance
- Polymorphism
Answer: C) Inheritance
Explanation:
The relationship between base class and derived class comes under the inheritance.
50. Which one of the following defines correct differences between structure and class?
- Structure only holds the data, classes hold the data and functions
- The structure holds the data and functions, classes only hold the data
- The structure is the instance of the class, classes are a set of objects
- Members of structure and class can be both public and private
Answer: A) Structure only holds the data, classes hold the data and functions
Explanation:
Structure only holds the data and Classes hold the data and functions both.
51. Which access specifier makes the class member accessible outside the class but can be accessed by any subclass of that class?
- Private
- Public
- Protected
Answer: C) Protected
Explanation:
Protected access specifier makes the class member accessible outside the class but can be accessed by any subclass of that class.
52. Which access specifiers have strict access control?
- Private
- Public
- Protected
Answer: A) Private
Explanation:
Private access specifier has a strict access control only members of the class can access private members.
53. What are auto variables?
- Auto variables are the variables that are visible to all the modules of a program
- Auto variables are the variables that speed up the allocation of the CPU
- Auto variables are the variables that are defined inside a function
- Auto variables are the variables whose scope is limited
Answer: A) Auto variables are the variables that are visible to all the modules of a program
Explanation:
Auto variables are the variables that are visible to all the modules of a program. All the variables are defined as auto variables by default.
54. What are Static variables?
- Static variables are the variables that are visible in specific functions
- Static variables are the variables that speed up the allocation of the CPU
- Static variables are the variables that are defined within a function and retain their values from the previous call
- All the variables are static variables by default
Answer: C) Static variables are the variables that are defined within a function and retain their values from the previous call
Explanation:
Static variables are the variables that are defined within a function and retain their values from the previous call.
55. When an object is created an initialization needs to be done which is automatically done by the ____ function?
- Constructor
- Destructor
- Friend
- Member
Answer: A) Constructor
Explanation:
When an object is created an initialization needs to be done which is automatically done by the constructor function, it constructs the value of the member class.
56. Which one of the following is not the characteristic of a constructor?
- Constructors can be virtual
- Constructors cannot be referred by their address
- Constructors cannot be inherited
- Constructors are called automatically
Answer: A) Constructors can be virtual
Explanation:
Constructors cannot be virtual, because there is not a virtual table in the memory.
57. The _____ constructor is invoked when an object is passed by value to a function.
- Parameterized Constructor
- Default Constructors
- Copy Constructor
Answer: C) Copy Constructor
Explanation:
Copy Constructor is invoked when an object is passed by value to a function.
58. What are private constructors?
- A private constructor is a special instance constructor.
- Private constructors are the constructors which can be used on the object without being explicitly defined.
- Only (i)
- Only (ii)
- Both (i) and (ii)
- There is no concept of private constructors.
Answer: A) Only (i)
Explanation:
A private constructor is a special instance constructor, which has no other arguments.
59. Which one of the following is the main benefit of single inheritance?
- Presence of ambiguity
- Absence of ambiguity
- Provides modularity
- Does not provide modularity
Answer: B) Absence of ambiguity
Explanation:
The absence of ambiguity is one of the following are main benefits of single inheritance.
60. How many types of valid inheritance are there?
- 4 types
- 5 types
- 6 types
- 3 types
Answer: B) 5 types
Explanation:
There are total 5 types of inheritances – Single, Multiple, Hybrid, Hierarchical, and Multilevel.
61. In which type of inheritance the child or derived class inherits the features of the superclass and simultaneously this child class acts as a superclass for another derived class?
- Hybrid inheritance
- Multiple inheritances
- Hierarchical inheritance
- Multilevel inheritance
Answer: D) Multilevel inheritance
Explanation:
In Multilevel inheritance, the child or derived class inherits the features of the superclass, and simultaneously these child class acts as a superclass for another derived class.
62. In which type of inheritance does one class act as a superclass for more than one sub-class?
- Hybrid inheritance
- Multiple inheritances
- Hierarchical inheritance
- Multilevel inheritance
Answer: C) Hierarchical inheritance
Explanation:
In Hierarchical inheritance one class act as a superclass for more than one subclass.
63. The default visibility mode in inheritance is ____?
- Protected
- Public
- Private
Answer: C) Private
Explanation:
The default visibility mode in inheritance is private.
64. If the base class is inherited privately then the public members of the base class become protected members of the derived class and the protected members of the base class become public members of the derived class?
Is this statement True or False?
- True
- False
Answer: B) False
Explanation:
If the base class is inherited privately then the public members of the base class become private members of the derived class and the protected members of the base class become private members of the derived class.
65. When we override an inherited method in a subclass, we can _____ its access but not ____ it?
- Increase, decrease
- Decrease, increase
Answer: A) Increase, decrease
Explanation:
When we override an inherited method in a subclass, we can increase its access but not decrease it.
66. This is the type of inheritance in which the implementation of a superclass is incomplete.
- Single inheritance
- Virtual inheritance
- Multiple inheritances
- Hybrid inheritance
Answer: B) Virtual inheritance
Explanation:
Virtual inheritance is a type of inheritance in which the implementation of a superclass is incomplete.
67. Virtual inheritance is also known as ____.
- Clear inheritance
- Private inheritance
- Disinheritance
- Multiple inheritances
Answer: C) Disinheritance
Explanation:
Virtual inheritance is also known as Disinheritance.
68. Which class is mainly designed to overcome the disadvantage of multiple inheritances?
- Virtual Base class
- Base class
- Abstract class
- Partial class
Answer: A) Virtual Base class
Explanation:
Virtual base classes are mainly designed to overcome the disadvantage of multiple inheritances.
69. _____ is the relationship between a class and one or more refined versions of it.
- Special inheritance
- Generalization
- Inheritance
Answer: B) Generalization
Explanation:
Generalization is the relationship between a class and one or more refined versions of it.
70. Which concept of object-oriented programming language does not use base class and derived class?
- Polymorphism
- Abstraction
- Over ridding
Answer: A) Polymorphism
Explanation:
Polymorphism does not use base class and derived class.
71. _____ is associated with polymorphism and inheritance.
- Message parsing
- Abstraction
- Dynamic Binding
- Encapsulation
Answer: C) Dynamic Binding
Explanation:
Dynamic Binding is associated with polymorphism and inheritance.
72. See the following diagram and identify the type of association?
- One-to-One association
- Many-to-Many association
- Ternary association
Answer: A) One-to-One association
Explanation:
The following diagram depicts the one-to-one association as every country has a capital city.
73. How many types of associations are there?
- 2 types
- 3 types
- 4 types
- It does not have any type
Answer: B) 3 types
Explanation:
There are three types of associations: One-to-one association, Many-to-Many association, and Ternary association.
74. Are aggregation and generalization the same thing?
- Yes
- No
Answer: B) No
Explanation:
No, aggregation and generalization are not the same things as aggregation relates to instances and generalization relates to classes.
75. A class containing one or more pure virtual functions is known as ____?
- Abstract class
- Static class
- Instance class
Answer: A) Abstract class
Explanation:
A class containing one or more pure virtual functions is known as an Abstract class.
76. Can we create an object of abstract class type?
- Yes
- No
Answer: B) No
Explanation:
We cannot create an object of abstract class type.
77. State whether a statement is true or false?
Derived classes cannot be built from abstract classes.
- True
- False
Answer: B) False
Explanation:
Derived classes can be built from abstract classes.
78. _____ refers to the ability to perform operations without knowing the type of object they’ll be operated on.
- Abstract base class
- Abstract class
- Polymorphism
- Operator overloading
Answer: C) Polymorphism
Explanation:
Polymorphism refers to the ability to perform operations without knowing the type of object they’ll be operated on.
79. What is early binding?
- Early binding simply means that an object is bound to its function call at compile time
- Early binding simply means that an object is bound to its function call at runtime
Answer: A) Early binding simply means that an object is bound to its function call at compile time
Explanation:
Early binding simply means that an object is bound to its function call at compile time.
80. Early binding is also known as____?
- Dynamic binding
- Late binding
- Static binding
- Run time binding
Answer: C) Static binding
Explanation:
Early binding is also known as static binding.
81. Which of the following statement is not true for virtual functions?
- The virtual function must be members of some class
- The virtual function can be a static member
- Virtual functions are accessed by using an object pointer
- The virtual function can be a friend of another class
Answer: B) The virtual function can be a static member
Explanation:
Virtual function cannot be a static member.
82. If the virtual function is defined in the base class, it needs not be necessarily redefined in the derived class.
Is this statement true or false?
- True
- False
Answer: A) True
Explanation:
If the virtual function is defined in the base class, it needs not be necessarily redefined in the derived class. In such cases, calls will invoke the base function.
83. If two functions with the same name have different prototypes, C++ considers them as ____?
- Friend Function
- Overloaded function
- Abstract function
- Operator overloading function
Answer: B) Overloaded function
Explanation:
If two functions with the same name have different prototypes, C++ considers them as overloaded functions.
84. ____ Function is a function declared in a base class that has no definition relative to the base class.
- Virtual Function
- Pure Virtual Function
- Friend Function
- Static Function
Answer: B) Pure Virtual Function
Explanation:
Pure virtual Function is a function declared in a base class that has no definition relative to the base class.
85. Can a destructor be virtual?
- Yes
- No
Answer: A) Yes
Explanation:
Destructors are declared as virtual.
86. Can a constructor be virtual?
- Yes
- No
Answer: B) No
Explanation:
Constructors cannot be virtual.
87. ____ is a mechanism that helps us to get compile-time polymorphism.
- Function Overloading
- Function Overriding
Answer: A) Function Overloading
Explanation:
Function Overloading is a mechanism that helps us to get compile-time polymorphism.
88. Which function is not a member of a class but still has access to private data of a class?
- Friend Function
- Pure Virtual Function
- Static Function
- Abstract Function
Answer: A) Friend Function
Explanation:
The friend function is not a member of a class but still has access to the private data of a class.
89. State the correct syntax of a friend function.
- Class ABC{
- *****
- Friend public:
- *****
- Void xyz(); }
- Class ABC{
- *****
- public:
- *****
- Friend Void xyz(); }
- Class ABC{
- *****
- Friend public:
- *****
- Friend Void xyz(); }
- Class ABC{
- *****
- public::friend()
- *****
- Friend Void xyz(); }
Answer: B)
Class ABC{
*****
public:
*****
Friend Void xyz(); }
Explanation:
The correct syntax of a friend function:
Class ABC{
*****
public:
*****
Friend Void xyz(); }
90. ‘Friend Functions cannot access the private data of other class’. Is this statement true or false?
- True
- False
Answer: B) False
Explanation:
Friend Functions can access the private data of other classes.
91. How many types of parameter parsing does C++ support?
- 2 types
- 3 types
- 4 types
Answer: B) 3 types
Explanation:
3 types of parameter parsing are supported by C++. They are as follows: Pass by value, Pass by address, Pass by reference.
92. Which statement tells the correct difference between Exception and Error?
- An exception cannot be recovered. Errors can be recovered.
- An exception can be recovered. Errors cannot be recovered.
Answer: B) An exception can be recovered. Errors cannot be recovered.
Explanation:
Exceptions can be recovered by try-catch blocks, Errors cannot be recovered.
93. Does an exception occur?
- Runtime
- Compile-time
Select the correct option?
- Only i
- Only ii
- Both i and ii
Answer: C) Both i and ii
Explanation:
Exception occurs at both runtime and compiles time.
94. Select the correct operator which cannot be overloaded.
- Scope Resolution Operator (::)
- Ternary Operator (? 🙂
- Member Access or Dot Operator (.)
- All of the above
Answer: D) All of the above
Explanation:
Scope Resolution Operator (::), Ternary Operator (? :), Member Access or Dot Operator (.) these are the operators which cannot be overloaded.
95. Watch the diagram closely and identify the type of inheritance?
- Hierarchical inheritance
- Hybrid inheritance
- Multilevel inheritance
- Multiple inheritances
Answer: B) Hybrid inheritance
Explanation:
Hybrid inheritance is the combination of multiple and multilevel inheritances so therefore in the given diagram, lecturer, department, the student refers as multilevel inheritance and marks and students refer as multiple inheritances.
96. The syntax is given below shows which type of inheritance?
18. class A {
… .. … };
class B: public A {
… .. … };
class C: public B {
… … … };
- Hierarchical inheritance
- Hybrid inheritance
- Multilevel inheritance
- Multiple inheritances
Answer: C) Multilevel inheritance
Explanation:
In the given syntax, class B is derived from the base class A and class C is derived from the derived class B.
97. Which operator is used to access the static variable and static function of a class?
- Scope Resolution Operator (::)
- Ternary Operator (? 🙂
- Member Access or Dot Operator (.)
- All of the above
Answer: A) Scope Resolution Operator (::)
Explanation:
Scope Resolution Operator (::), is used to access the static variable and static function of a class.
98. The scope resolution operator is used to ____ function in the Inheritance.
- Overload
- Override
Answer: B) Override
Explanation:
Scope Resolution Operator (::), is used to override function in the Inheritance.
99. If there are different sections of an organization such as IT, computer science, Civil, Mechanical, etc. Each organization has the same attributes such as student name, roll number, year, etc. which comes under a class Student then this comes under which type of inheritance?
- Hierarchical inheritance
- Hybrid inheritance
- Multilevel inheritance
- Multiple inheritances
Answer: A) Hierarchical inheritance
Explanation:
All the sections inherit the student properties and thus follow the format of hierarchical inheritance.
100. How many types of functions are there in an object-oriented programming language?
- 4 types
- 5 types
- 2 types
- 6 types
Answer: B) 5 types
Explanation:
There are 5 types of functions in Object-oriented programming languages, they are: Simple functions, Static functions, Const functions, Inline functions, and Friend functions.