Home Tuitions

CUET CS Chapter-Inheritance

Board CBSE
Textbook NCERT
Class Class 12
Subject Computer Science
Chapter CUET CS Chapter-Inheritance
Chapter Name Inheritance
Category CUET (Common University Entrance Test) UG

MCQ-Based Questions for CUET Computer Science Chapter-Inheritance  

This page is prepared by HT experts and consists of MCQ-Based Questions for CUET Computer Science chapter-Inheritance with a detailed explanation of all the questions asked from Inheritance. To find the solution to the MCQ questions click on the answer tab. Check out chapter-wise CUET computer science Practice MCQ Based Questions. 

Practice Questions for CUET Computer Science chapter-Inheritance SET-1

Computer Science - MCQ on Inheritance : Extending Classes

Class XII

Q.1 The property of an object oriented language that lets us to generate a model which is closer to the real world model is

a) polymorphism.

b) inheritance.

c) abstraction.

d) encapsulation.

Answer:

(b)

Explanation: Inheritance is the capability of one class to inherit the properties of another class. Example: class cars inherit the properties from automobiles, which itself inherits from another class vehicles.

Q.2 The most important advantage of inheritance is reusability. Reusing an existing code

a) increases readability.

b) increases time, money and efforts to use the code again.

c) increases reliability of a program.

d) increases writability.

Answer:

(c)

Explanation: Reusability is using the already tested and saved previous code again. It’s advantages are faster development time, easier maintenance, and easy to extend.

Q.3 The class which inherits the properties of another class is known as the

a) derived class.

b) super class.

c) base class.

d) inheritable class.

Answer:

(a)

Explanation: Derived classes (sub-classes) inherit the properties of a base class (super class).

Q.4 The class whose properties are inherited by other classes is known as the

a) base class.

b) derived class.

c) derivable class.

d) inherited class.

Answer:

a)

Explanation: Derived classes, inherit properties, including the methods of old classes, which are called as base class, or super class.

Q.5 When many subclasses inherit a single base class, it is known as

a) single inheritance

b) multilevel inheritance.

c) multiple inheritance

d) hierarchical inheritance

Answer:

(d)

Explanation: All subclasses will have properties inherited from the single base class or super class

Q.6 The transitive nature of inheritance is reflected by

a) single inheritance.

b) multilevel inheritance.

c) multiple inheritance.

d) hierarchical inheritance.

Answer:

(b)

Explanation: Multilevel inheritance is when a subclass inherits a class that itself inherits another class.

Q.7 Combining two or more forms of inheritance, is called as

a) multiple inheritance.

b) hybrid inheritance.

c) binary inheritance.

d) hierarchical inheritance.

Answer:

(b)

Explanation: Hybrid inheritance is, when a sub class inherits multiple base classes and all of its base classes inherit a single base class.

Q.8 The syntax of defining a derived class (using single inheritance) is

a) class derived –class-name : visibility-mode base class name{ : // members of derived class };

b) class derived –class-name ;visibility-mode base class name{ : // members of derived class };

c) class derived –class-name ; visibility-mode base class name{ ; // members of derived class };

d) class derived –class-name : { : // members of derived class };

Answer:

a)

Explanation: The colon indicates that sub class is based upon the super class.

Q.9 The derived class has access privilege to only the

a) non private members of the base class.

b) private members of the base class.

c) public members of the derived class.

d) protected members of the base class.

Answer:

a)

Explanation: The derived class cannot access the private members of its super class.

Q.10 The mode that controls the availability of inherited base class members in the derived class is called as

a) on mode.

b) off mode.

c) visibility mode

d) access specifiers.

Answer:

c)

Explanation: There are three visibility modes: private, protected, and public.

Q.11 If visibility mode is public, then the inheritable protected members of base class becomes

a) private in derived class.

b) protected in derived class.

c) unprotected in derived class.

d) public in derived class.

Answer:

(b)

Explanation: Visibility mode specifies whether the features of the base class are privately derived, or publicly derived or protected derived.

Q.12 The derivation that does not changes the access specifiers for inherited members in the derived class is

a) public derivation.

b) protected derivation.

c) private derivation.

d) unprotected derivation.

Answer:

a)

Explanation: In public derivation, the inherited members need not be re-defined in the derived class.

Q.13 The visibility mode which means that derived class can access the public and protected members of base class but not the private members of the base class is

a) private visibility mode.

b) protected visibility mode.

c) public visibility mode.

d) unprotected visibility mode.

Answer:

c)

Explanation: With publicly derived class, public members becomes the public members of derived class and protected becomes the protected members of derived class.

Q.14 The visibility mode, which means that the derived class can access the public and private members of the base class, is

a) private visibility mode.

b) protected visibility mode.

c) public visibility mode.

d) unprotected visibility mode.

Answer:

a)

Explanation: There are three access specifiers: private, public and protected. Visibility mode specifies whether the features of a base class is privately derived or publicly derived.

Q.15 With privately derived class, the public and protected members of the base class become

a) public members of derived class.

b) private members of derived class.

c) protected members of derived class.

d) unprotected members of derived class.

Answer:

(b)

Explanation: This means that inherited members can be accessed only through member functions of the derived class.

Q.16 When the features are required to be hidden from the outside world and at the same time, required to be inheritable then we should

a) derive publicly.

b) derive protectedly.

c) derive privately.

d) not use inheritance.

Answer:

(b)

Explanation: Protected inheritance should be used when the situation requires the attributes of base class to be available only to the derived classes’ members but not to the outside world.

Q.17 When the derived class wants to use some attributes of the base class and these inherited features can’t be inherited further, then we should use

a) private derivation.

b) public derivation.

c) protected derivation.

d) unprotected derivation.

Answer:

a)

Explanation: Private inheritance should be used when the derived classes cannot be viewed as a type of their base class.

Q.18 The inheritance that does not reflects the object oriented design of the system is called

a) public inheritance.

b) protected inheritance.

c) private inheritance.

d) constructor inheritance.

Answer:

c)

Explanation: It simply reflects an implementation shortcut.

Q.19 When a derived class wants to access all the attributes of the base class, and also wants some extra attributes to be defined, then it is

a) private derivation.

b) public derivation.

c) protected derivation.

d) unprotected derivation.

Answer:

(b)

Explanation: The public inheritance is appropriate to most well designed object-oriented systems.

Q.20 The inheritance that is most appropriate to well designed object oriented systems is

a) private inheritance.

b) public inheritance.

c) protected inheritance.

d) unprotected inheritance.

Answer:

(b)

Explanation: Deriving publicly is a way of saying, “ is a type of “.

Q.21 When an object of a derived class is created, the program first

a) calls the constructor for derived class, then the constructor for base class.

b) calls the destructor for derived class, then the constructor for base class.

c) calls the constructor for base class, then the destructor for derived class.

d) calls the constructor for base class ,then the constructor for derived class.

Answer:

(d)

Explanation: It makes sense, as the constructor for the derived class is build upon data members of the base class.

Q.22 When an object of a derived class expires, the sequence in which the destructor is invoked is

a) derived class destructor followed by base class destructor is invoked.

b) base class destructor followed by derived class destructor is invoked.

c) only base class destructor is invoked.

d) only derived class destructor is invoked.

Answer:

a)

Explanation: It is analogous in the same way, as while destroying a building first second floor is destroyed and then first floor.

Q.23 Constructors and destructors of a base class

a) are same as that of that derived class.

b) can not be inherited by derived class.

c) can be inherited by derived class.

d) can not be invoked by derived class by explicitly calling them.

Answer:

(b)

Explanation: Derived classes cannot inherit but invoke the constructor or destructor of a base class by explicitly calling them.

Q.24 If we declare a class without any data member, then the size of that class

a) is 0 byte.

b) is 1 byte.

c) is 2 byte.

d) can not be determined.

Answer:

(b)

Explanation: An empty class has size 1 byte. It cannot have 0 byte size.

Q.25 The correct statement is

a) The private members of the base class are visible in the derived class but they are not directly accessible.

b) The private members of the base class are not visible in the derived class and not accessible.

c) The private members of the base class are not visible in the derived class but they are directly accessible.

d) The private members of the base class are visible and directly accessible in the derived class.

Answer:

(a)

Explanation: Private members of a base class are not directly accessible in the base class but this does not affects their visibility.

Q.26 In C++ programs, when an object is first created the special member function which is automatically called is

a) destructor.

b) constructor.

c) malloc().

d) calloc().

Answer:

(b)

Explanation: The constructor is a special member function that allows us to set up values while defining the object, without the need to make a separate call to a member function.

Q.27 When an object is destroyed the function which automatically gets called is

a) destructor.

b) constructor.

c) malloc().

d) calloc().

Answer:

a)

Explanation: The destructors are used to deallocate memory that was allocated for the object by the constructor.

Q.28 Abstract class cannot have

a) zero instance.

b) any instance.

c) multiple instance.

d) zero and multiple instance.

Answer:

(b)

Explanation: An abstract class is a class, which cannot be instantiated. It has no instances. Abstract classesare the classes that contain one or more abstract methods. An abstractmethod is a method that is declared, but contains no implementation.

Q.29 The logical abstract base class for a class called “footballPlayer “ is

a) salary.

b) sport.

c) athlete.

d) team.

Answer:

c)

Explanation: An abstract class is a class, which cannot be instantiated. It has no instances.

Q.30 The inheritance that allows the a derived class to combine the strength of all the base classes is

a) multiple inheritance.

b) multilevel inheritance.

c) hierarchical inheritance.

d) single inheritance.

Answer:

a)

Explanation: Multiple inheritance is when a subclass inherits from multiple base classes.

Q.31 When a derived class and its base class have common ancestor, then ambiguity may arise as the derived class contains multiple copies of common ancestor. This can be resolved

a) only by using scope resolution operator.

b) only using virtual.

c) by either using virtual or scope resolution operator.

d) by nesting classes.

Answer:

c)

Explanation: We can declare common ancestor as virtual, or use:: operator.

Q.32 When a class contains objects of another class inside it, then it is called as

a) nesting of classes.

b) nesting of objects.

c) inheritance of class.

d) polymorphism of class.

Answer:

(b)

Explanation :In such a situation, the contained objects are constructed first and then objects of enclosing class are constructed.

Q.33 When a class contains objects of other types as its member, it is referred to as

a) containership.

b) polymorphism.

c) inheritance.

d) encapsulation.

Answer:

(a)

Explanation: Creation of an object that contains another object is very different than the creation of an independent object. The other terms of containership are aggregation, containment, or composition or nesting.

Q.34 When we add new refinements in the derived class then

a) the derived class automatically changes its name.

b) the base class is deleted.

c) the base class remains unchanged.

d) these changes are reflected in the base class also.

Answer:

c)

Explanation: The process of creating new classes, called derived classes from the old, existing ones, base a class is inheritance. The derived classes inherit all the properties of bas class and can add features of its own.

Q.35 When a base class has protected members, these are

a) public to derived classes but private to the rest of the program.

b) private to derived classes and to the rest of the program.

c) private to derived classes but public to the rest of the program.

d) public to derived classes and to the rest of the program.

Answer:

a)

Explanation: public, private and protected are the three access specifiers.

Q.36 A program can declare objects of both the base and derived classes, which

a) are dependent on each other.

b) are independent of each other.

c) are same, for base class and derived class.

d) can never be same in any condition.

Answer:

(b)

Explanation: Different objects of base class and derived class are legal.

Q.37 The declaration statement “ class xyitem: private item, private sales” indicates that

a) the class sales and item has been derived from class xyitem.

b) the class sales has been derived from two classes xyitem and item.

c) the class xyitem and item has been derived from class sales.

d) the class xyitem has been derived from two classes item and sales.

Answer:

(d)

Explanation: xyitem is a subclass and classes item and sales are superclasses.

Practice Questions for CUET Computer Science chapter-Inheritance SET-2

Q.38 The size of a derived class object is equal to

a) the size of data members in the base class.

b) the size of data members in the derived class.

c) the sum of sizes of data members in base class and the derived class.

d) 20 bytes always.

Answer:

c)

Explanation: Derived class inherits all the properties of base class and adds some features of its own.

Q.39A class “computer science” can be derived from class “ subjects”, which is derived from class “studies”, which is derived from class “school “. This is known as

a) multiple levels of inheritance.

b) single inheritance.

c) hierarchical inheritance.

d) multiple inheritance.

Answer:

a)

Explanation: When a subclass inherits from a class which itself inherits from another class, this is known as multilevel inheritance.

Q.40 An object of a derived class (which itself is derived from another class)

a) can access private members of base class.

b) can access protected members of base class.

c) cannot access private or protected members of base class.

d) cannot access public members of base class.

Answer:

c)

Explanation: The private members of the base class are never accessible outside the class. The protected members of the base class are accessible only to the derived classes.

Computer Science - MCQ on Inheritance : Extending Classes

Class XII

Q.1 When we want the features to be available to the members and at the same time inheritable but hidden from the outside world, then we use

a) private inheritance.

b) public inheritance.

c) protected inheritance.

d) general inheritance.

Answer:

c)

Explanation: Protected inheritance should be used when the situation requires the attributes of the base class to be available only to the derived classes members’ but not to the outside world.

Q.2 Once we derive a class we

a) can add new members to it.

b) can not add new members to it.

c) have to add new members to it, otherwise the class can not be accessed.

d) have to redefine the base class variables and members.

Answer:

a)

Explanation: When we derive a class, we may or may not add new members to it. But, to construct new members new constructor (s) must be written for the derived class.

Q.3 Derived class constructor

a) can only accept arguments for itself.

b) can only accept arguments for its base class constructor.

c) can accept arguments for itself as well as for its base class constructor.

d) can not accept any arguments.

Answer:

c)

Explanation: The derived class constructor can invoke base class constructor, by passing appropriate arguments that it received for base class constructor.

Q.4 If the base class source code is not available, then

a) we cannot derive a class from the base class.

b) we can derive a class from the base class.

c) we can partially derive a class from the base class.

d) first we have to find the source code, then only the class can be derived.

Answer:

(b)

Explanation: We just want the base class declaration, to derive a class from a base class. The declaration is generally present in the header files.

Q.5 It is possible to derive a class through

a) public derivation only.

b) private derivation only.

c) protected derivation only.

d) public, private and protected derivation.

Answer:

(d)

Explanation: A class can be derived publicly, privately or protectedly. All three types of inheritance are possible.

Q.6 A class “computer science” is derived from the class “employees”, which is derived from the class “Extramarks”. This is an example of

a) multiple inheritance.

b) multilevel inheritance

c) hierarchical inheritance.

d) single inheritance.

Answer:

(b)

Explanation: In multilevel inheritance, a derived class itself acts as a base class for other classes.

Q.7 If the base class and a derived class each include a member function with the same name, the member function

a) of the derived class will be called by an object of the base class.

b) of the derived class will be called by an object of the derived class.

c) of the base class will be called by an object of derived class.

d) of the base class will be called by an object of any class.

Answer:

(b)

Explanation: The member functions are always searched in the derived class and then in the base class.

Q.8 When a function call gets resolved at compile time, it is called as

a) dynamic binding.

b) static binding.

c) late binding.

d) null binding.

Answer:

(b)

Explanation: The other name for static binding is early binding, which is done at compile time.

Q.9 Creating pointer of an abstract class is

a) legal in C++ only.

b) illegal in C++.

c) not possible either in C++ or C.

d) valid in C and C++.

Answer:

(d)

Explanation: Even though, we cannot create an object of an abstract class, but we can create a pointer of an abstract class.

Q.10 Among the following, the true statement is

a) Creating a derived class from a base class requires fundamental changes to the base class.

b) In private inheritance, part of the base class interface can be made available to the functions outside the derived class.

c) The size of a derived class object is equal to the size of data members in the derived class only.

d) It is illegal to make objects of one class as members of another class.

Answer:

(b)

Explanation: When we inherit privately, all public members of the base class become private for the derived class. If we want only some of them to remain private and the rest to be accessible from outside the derived class, it can also be done.

Q.11 If we make some additions to the derived class, then

a) the base class also changes.

b) these changes are inflicted in the base class and derived class remains same.

c) both the base class and derived class changes.

d) the derived class changes whereas base class remains unchanged.

Answer:

(d)

Explanation: A derived class inherits all the features of a base class, and can add new features to it. But, by making these additions base class remains unchanged.

Q.12 If we think of the behavior of access specifiers we can see that, protected members behave just like

a) public members.

b) global members.

c) private members until, a new class is derived from the base class that has protected members.

d) local functions.

Answer:

c)

Explanation: The protected keyword specifies access to class members in the member-list up to the next access specifier (public or private) or the end of the class definition.

Q.13 A base class that appears directly as a base specifier in the declaration of its derived class is called as

a) direct base class.

b) indirect base class.

c) general base class.

d) double base class.

Answer:

a)

Explanation: A base class is one whose properties are derived by other classes.

Q.14 A base class that does not appear directly in the declaration of derived class, but is available to the derived class through one of its base classes is called as

a) direct base class.

b) indirect base class.

c) general base class.

d) double base class.

Answer:

(a)

Explanation: For a given class, all base classes that are not direct base classes are indirect base classes.

Q.15 The functions that can be applied to objects of more than one type are called

a) double functions.

b) global functions.

c) polymorphic functions.

d) direct functions.

Answer:

c)

Explanation: Polymorphic functions can be implemented using overloading functions and virtual functions.

Q.16 When a class is derived privately from a base class, all protected base class members become

a) public members of the derived class.

b) private members of the derived class.

c) protected members of the derived class.

d) global members.

Answer:

(b)

Explanation: A protected non-static base class member can be accessed by members and friends of any classes derived from that base class.

Q.17 A derived class can inherit an indirect base class

a) only once.

b) only twice.

c) more than once.

d) which is illegal in C++.

Answer:

c)

Explanation: It is valid when a derived class inherits an indirect base class more than once.

Q.18 Deriving a class from more than one base class is called

a) single inheritance.

b) multiple inheritance.

c) multilevel inheritance.

d) hierarchical inheritance.

Answer:

(b)

Explanation: We can derive a class from any number of base classes in multiple inheritance.

Q.19 If we want the compiler to use dynamic binding for the specific function, then we declare the function with the keyword

a) virtual.

b) friend.

c) abstract.

d) public.

Answer:

a) Explanation: We can specify that the compiler match a function call with the correct function definition at run time; this is called dynamic binding.

Q.20 When a base class and a derived class have public member functions with the same name and parameter list types, then

a) the function in the derived class gets higher priority, when the function is called as a member of the derived class object.

b) the function in the base class gets higher priority, when the function is called as a member of the derived class object.

c) the function in the derived class gets higher priority, when the function is called as a member of the base class object.

d) the function in the base class gets higher priority always.

Answer:

a) Explanation: The derived class is one, which derives properties of base class.