OOPs MCQs

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.

  1. Classes
  2. Objects
  3. Variables
  4. 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.

  1. Objects
  2. Classes
  3. Operating system
  4. 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 ____?

  1. String
  2. Boolean
  3. Class
  4. 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?

  1. Data encapsulation
  2. Collection of objects of similar type
  3. Inheritance
  4. 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)?

  1. Because classes are user-defined data types
  2. Because it supports the theory of hierarchical classification
  3. Because it allows dynamic binding
  4. 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).


Advertisement

6. Which is not true about the object-oriented approach?

  1. Emphasis is on data rather than procedure
  2. Data is hidden and cannot be accessed by external functions
  3. Objects communicate through functions
  4. 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?

  1. Modula-3
  2. Ada 95
  3. Modula-2
  4. 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?

  1. Modula-3
  2. 83 Ada
  3. Modula-2
  4. Ada 95
  5. 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?

  1. Inheritance
  2. Dynamic binding
  3. Only A
  4. 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?

  1. Object-based approach
  2. Object-oriented approach

Answer: B) Object-oriented approach

Explanation:

Object-oriented approach supports all the features along with inheritance and dynamic binding.


Advertisement

11. What is procedure-oriented Language?

  1. A procedure-oriented Language is a language that incorporates all object-oriented programming features
  2. A procedure-oriented Language is a language that supports encapsulation and object identity
  3. A procedure-oriented Language is a language that consists of writing a list of instructions
  4. 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?

  1. A procedure-oriented language does not model real-world problems
  2. In procedure-oriented Language message parsing is difficult
  3. A procedure-oriented Language works slowly
  4. 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?

  1. A procedure-oriented language emphasizes data rather than procedure.
    An object-oriented language emphasizes doing things or algorithms.
  2. A procedure-oriented language emphasizes doing things or algorithms.
    An object-oriented language emphasizes data rather than procedure.
  3. In procedure-oriented programs are decomposed into functions.
    In an object-oriented language, large programs are decomposed into functions.
  4. In procedure-oriented language, large programs are decomposed into functions
    In an object-oriented language, programs are decomposed into functions.
  5. Both (a) and (b)
  6. 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?

  1. Top-down approach
  2. 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?

  1. Top-down approach
  2. 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.


Advertisement

16. Which feature's behavior of OOP depends upon the types of data used in the operation.

  1. Inheritance
  2. Polymorphism
  3. Abstraction
  4. 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?

  1. Dynamic binding
  2. Abstraction
  3. Operator overloading
  4. 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?

  1. FORTAN
  2. RUBY
  3. JADE
  4. 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?

  1. Static functions
  2. Const functions
  3. Inline functions
  4. 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.

  1. Class Methods
  2. Static Methods
  3. Instance Methods
  4. Interface Methods

Answer: C) Instance Methods

Explanation:

The subroutines contained in an object are called instance methods.


Advertisement

21. Which function incorporates a membership 'identity label' in the header?

  1. Member functions
  2. Normal functions
  3. Inline functions
  4. 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?

  1. Private data
  2. Public data
  3. Protected data
  4. 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?

  1. True
  2. 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?

  1. Static
  2. Local
  3. Global
  4. 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.

  1. Class name
  2. 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?

  1. 2 types
  2. 3 types
  3. 4 types
  4. 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?

  1. Action Abstraction
  2. Virtual Machine Abstraction
  3. Coincidental Abstraction
  4. 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?

  1. Action Abstraction
  2. Virtual Machine Abstraction
  3. Coincidental Abstraction
  4. 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?

  1. Action Abstraction
  2. Virtual Machine Abstraction
  3. Coincidental Abstraction
  4. 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?

  1. Action Abstraction
  2. Virtual Machine Abstraction
  3. Coincidental Abstraction
  4. 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.


Advertisement

31. ____ is the process of compartmentalizing the elements of an abstraction that contribute to its structure and behavior?

  1. Encapsulation
  2. Abstraction
  3. Classes
  4. 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?

  1. Typing
  2. Concurrency
  3. Hierarchy
  4. 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?

  1. Object
  2. Concurrency
  3. Hierarchy
  4. 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?

  1. Manipulators are used to specify a character that is used to fill the unused portion of the field
  2. Manipulators are used to clear the flags specified
  3. Manipulators are special functions that can be included in the I/O statements to alter the format parameters of a stream
  4. 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.

  1. iomanip
  2. ios
  3. #include
  4. 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.

  1. istream
  2. ios
  3. ostream
  4. 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?

  1. ios stream class contains a pointer to a buffer object
  2. ios stream class inherits the properties of ios
  3. ios stream contains overloaded insertion operator<<
  4. 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?

  1. ios stream class inherits the properties of ios.
  2. ios stream contains overloaded extraction operator>>.
  3. Only A
  4. Only B
  5. 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?

  1. iostream class inherits the properties of ios.
  2. iosstream class inherits the properties of istream and ostream.
  3. Only A
  4. Only B
  5. 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.

  1. Static objects
  2. Dynamic objects
  3. External objects
  4. 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.

  1. Static objects
  2. Dynamic objects
  3. External objects
  4. 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.

  1. Static objects
  2. Dynamic objects
  3. External objects
  4. 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.

  1. Static objects
  2. 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?

  1. 2 types
  2. 3 types
  3. 4 types
  4. 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.

  1. Class diagram
  2. 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.

  1. Class diagram
  2. 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?

  1. A parameterized class is a class that denotes a family of classes whose structure and behavior are defined independently of its formal class parameter
  2. A parameterized class is a class that uses the concept of a Meta class
  3. 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?

  1. A Meta class is a class that may not itself have any instances.
  2. A Meta class is a class of a class.
  3. Meta classes are classes that are different than plain classes.
  4. 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?

  1. Abstraction
  2. Encapsulation
  3. Inheritance
  4. 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?

  1. Structure only holds the data, classes hold the data and functions
  2. The structure holds the data and functions, classes only hold the data
  3. The structure is the instance of the class, classes are a set of objects
  4. 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?

  1. Private
  2. Public
  3. 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?

  1. Private
  2. Public
  3. 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?

  1. Auto variables are the variables that are visible to all the modules of a program
  2. Auto variables are the variables that speed up the allocation of the CPU
  3. Auto variables are the variables that are defined inside a function
  4. 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?

  1. Static variables are the variables that are visible in specific functions
  2. Static variables are the variables that speed up the allocation of the CPU
  3. Static variables are the variables that are defined within a function and retain their values from the previous call
  4. 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?

  1. Constructor
  2. Destructor
  3. Friend
  4. 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?

  1. Constructors can be virtual
  2. Constructors cannot be referred by their address
  3. Constructors cannot be inherited
  4. 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.

  1. Parameterized Constructor
  2. Default Constructors
  3. 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?

  1. A private constructor is a special instance constructor.
  2. Private constructors are the constructors which can be used on the object without being explicitly defined.
  1. Only (i)
  2. Only (ii)
  3. Both (i) and (ii)
  4. 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?

  1. Presence of ambiguity
  2. Absence of ambiguity
  3. Provides modularity
  4. 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?

  1. 4 types
  2. 5 types
  3. 6 types
  4. 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?

  1. Hybrid inheritance
  2. Multiple inheritances
  3. Hierarchical inheritance
  4. 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?

  1. Hybrid inheritance
  2. Multiple inheritances
  3. Hierarchical inheritance
  4. 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 ____?

  1. Protected
  2. Public
  3. 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?

  1. True
  2. 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?

  1. Increase, decrease
  2. 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.

  1. Single inheritance
  2. Virtual inheritance
  3. Multiple inheritances
  4. 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 ____.

  1. Clear inheritance
  2. Private inheritance
  3. Disinheritance
  4. 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?

  1. Virtual Base class
  2. Base class
  3. Abstract class
  4. 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.

  1. Special inheritance
  2. Generalization
  3. 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?

  1. Polymorphism
  2. Abstraction
  3. Over ridding

Answer: A) Polymorphism

Explanation:

Polymorphism does not use base class and derived class.


71. _____ is associated with polymorphism and inheritance.

  1. Message parsing
  2. Abstraction
  3. Dynamic Binding
  4. 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?

OOPs MCQ - 72
  1. One-to-One association
  2. Many-to-Many association
  3. 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?

  1. 2 types
  2. 3 types
  3. 4 types
  4. 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?

  1. Yes
  2. 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 ____?

  1. Abstract class
  2. Static class
  3. 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?

  1. Yes
  2. 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.

  1. True
  2. 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.

  1. Abstract base class
  2. Abstract class
  3. Polymorphism
  4. 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?

  1. Early binding simply means that an object is bound to its function call at compile time
  2. 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____?

  1. Dynamic binding
  2. Late binding
  3. Static binding
  4. 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?

  1. The virtual function must be members of some class
  2. The virtual function can be a static member
  3. Virtual functions are accessed by using an object pointer
  4. 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?

  1. True
  2. 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 ____?

  1. Friend Function
  2. Overloaded function
  3. Abstract function
  4. 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.

  1. Virtual Function
  2. Pure Virtual Function
  3. Friend Function
  4. 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?

  1. Yes
  2. No

Answer: A) Yes

Explanation:

Destructors are declared as virtual.


86. Can a constructor be virtual?

  1. Yes
  2. No

Answer: B) No

Explanation:

Constructors cannot be virtual.


87. ____ is a mechanism that helps us to get compile-time polymorphism.

  1. Function Overloading
  2. 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?

  1. Friend Function
  2. Pure Virtual Function
  3. Static Function
  4. 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.

  1. Class ABC{
    *****
    Friend public:
    *****
    Void xyz(); }
  2. Class ABC{
    *****
    public:
    *****
    Friend Void xyz(); }
    
  3. Class ABC{
    *****
    Friend public:
    *****
    Friend Void xyz(); }
    
  4. 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?

  1. True
  2. 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?

  1. 2 types
  2. 3 types
  3. 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?

  1. An exception cannot be recovered. Errors can be recovered.
  2. 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?

  1. Runtime
  2. Compile-time

Select the correct option?

  1. Only i
  2. Only ii
  3. 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.

  1. Scope Resolution Operator (::)
  2. Ternary Operator (? :)
  3. Member Access or Dot Operator (.)
  4. 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?

OOPs MCQ - 72
  1. Hierarchical inheritance
  2. Hybrid inheritance
  3. Multilevel inheritance
  4. 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 { 
... ... ... };
  1. Hierarchical inheritance
  2. Hybrid inheritance
  3. Multilevel inheritance
  4. 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?

  1. Scope Resolution Operator (::)
  2. Ternary Operator (? :)
  3. Member Access or Dot Operator (.)
  4. 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.

  1. Overload
  2. 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?

  1. Hierarchical inheritance
  2. Hybrid inheritance
  3. Multilevel inheritance
  4. 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?

  1. 4 types
  2. 5 types
  3. 2 types
  4. 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.


ADVERTISEMENT
ADVERTISEMENT




Comments and Discussions!




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.