CUET Information practice (IP) Chapter 6 Inheritance

  • Board
    CBSE
  • Textbook
    NCERT
  • Class
    Class 12
  • Subject
    Informative Practices (IP)
  • Chapter
    CUET Information practice (IP) Chapter 6 Inheritance
  • Chapter Name
    Chapter 6 Inheritance
  • Category
    CUET (Common University Entrance Test) UG

Practice MCQ Based questions for CUET Information practice (IP) Chapter 6 Inheritance

This page is created by HT experts and consists of MCQ-based questions with detailed explanations for CUET Information practice (IP) Chapter 6 Inheritance. All the important concepts of Chapter 6 Inheritance for the CUET entrance exam are covered by MCQ questions with detailed explanations. Do solve chapter-wise MCQ questions for CUET Computer Science and CUET IP prepared by experts. 

MCQ Based questions for CUET Information practice (IP) Chapter 6 Inheritance Set-A

Informatics Practices - MCQ on Concept of Inheritance

Class XII

Q.1 The feature of Java in which a class can inherit the property of other class is

a) overriding.

b) overloading.

c) inheritance.

d) class.

Answer:

c)

Explanation:

º Inheritance is technique of organizing the information in a hierarchical form.

º It allows new classes to be built from older and less specialized classes instead of being rewritten from scratch.

Q.2 The base class is also known as

a) Parent class.

b) Child class.

c) Derive class.

d) Class.

Answer:

(a)

Explanation:

Base Class

º Basically, it is the existing class from which a new class can be derived.

º A base class is also known as Super Class/ Parent Class.

Q.3 The keyword used by a derive class to recognize its base class is

a) abstract.

b) extendz.

c) extends.

d) interface.

Answer:

(d)

Explanation:

º A derive class has to identify its base class.

º In java, the base class name has to be included in derive class definition.

º A derive class has to define the keyword extends along with the Base class name.

Q.4 Type of inheritance supported by java is

a) Single Inheritance.

b) Double Inheritance.

c) Multiple Inheritances.

d) Class Inheritance.

Answer:

a)

Explanation:

When a subclass is derived simply from its parent class then this mechanism is known as simple inheritance. In case of simple inheritance, there is only a subclass and its parent class. It is also called single inheritance or one level inheritance.

Q.5 Suppose there are three classes: Computer, Apple Computer and IBM Computer, the relationship between these classes is

a) Computer is the superclass; AppleComputer and IBMComputer are subclasses of Computer.

b) IBMComputer is the superclass; AppleComputer and Computer are subclasses of IBMComputer.

c) Computer, AppleComputer and IBMComputer are sibling classes.

d) Computer is a superclass, AppleComputer is a subclass of Computer and IBMComputer is a subclass of AppleComputer.

Answer:

(a)

Explanation:

º The Computer is a super class.

º IBM and Apple are their subclasses.

º So, IBM and Apple are inheriting there feature.

Q.6 Correct syntax for defining a new class Cokebased on the superclass SoftDrink is

a) class Coke is a SoftDrink.

b) class Coke implements SoftDrink.

c) class Coke defines SoftDrink.

d) class Coke extends SoftDrink.

Answer:

(d)

Explanation:

A derive class is defined by using the keyword extends along with the Base class name.

Q.7 A subclass can inherit

a) only member variables.

b) methods.

c) both member variables and methods.

d) only variables not the member function.

Answer:

(c)

Explanation:

Yes, a subclass can inherit data member and member function both but it is basically depend on there datatype/access specifiers.

Q.8 A disadvantage of using inheritance is

a) Code that is shared between classes needs to be written only once.

b) Similar classes can be made to behave consistently.

c) Enhancements to a base class will automatically be applied to derived classes.

d) One big superclass can be used instead of many little classes.

Answer:

(d)

Explanation:

º Inheritance is a technique of building new classes from the existing classes is called inheritance.

º It allows new classes to be built from older and less specialized classes instead of being rewritten from scratch.

Q.9 A class Animal has a subclass Mammal. So, we can say that

a) Mammalcan have no subclasses.

b) Mammalcan have no siblings.

c) Animal can have only one subclass.

d) Mammalcan have no other parent than Animal.

Answer:

(d)

Explanation:

Java doesn’t support the concept of multiple inheritances, which means a class can have just one superclass and not more than one superclass.

Q.10 A class Car and its subclass Honda City both have a method run() which was written by the programmer as a part of the class definition. If junker refers to an object of type Honda City, then the statement that is true for junker.show(); is

a) show() method defined in Honda City will be called.

b) show() method defined in Carwill be called.

c) the compiler will complain that run() has been defined twice.

d) overloading will be used to pick run().

Answer:

(a)

Explanation:

If the super class have a function with a same signature (same name, number and argument type) as in the sub class, then you try to use the method without explicity specifying its parent class name, only the subclass member would be invoked.

Q.11 The feature of java that shows the real world model is

a) inheritance.

b) abstract class.

c) interface.

d) base class.

Answer:

(a)

Explanation:

º Inheritance is everywhere in real life. You inherited your parent’s genes and acquired physical attributes from both of them.

º Technological products (computers, cell phones etc…) often inherit features from their predecessors.

Q.12 The derive class is also known as

a) Parent class.

b) Base class.

c) Super class.

d) Class.

Answer:

(a)

Explanation:

º Creating a new class from the base class is known as Derive Class.

º It can be changed.

º A Derive class may itself be a Base class from which additional class can be derived.

º A derive class is also known as Sub Class/ Child Class.

Q.13 The Base class

a) variable can be modified.

b) function can be modified.

c) variables can be modified, but not the function.

d) cannot be modified.

Answer:

(a)

Explanation:

º The member function and data member both cannot modify the base class.

º We can add the member function and data member in the derive class.

Q.14 In java class hierarchy, the root of the tree is

a) class.

b) base class.

c) derive class.

d) object.

Answer:

(d)

Explanation:

The java class hierarchy which graphically shows a tree with an Object as the root of the tree is known as inheritance graph.

Q.15 In java, every class can have

a) one immediate class.

b) class.

c) more than one immediate class.

d) no immediate class.

Answer: Explanation:

 

Every class in java has one immediate class/ direct superclass, but might have several subclasses.

Q.16 Reusability feature comes under the concept of

a) interface.

b) abstract class.

c) inheritance

d) class.

Answer:

(c)

Explanation:

The concept of inheritance provides the idea of reusability. This means that we can add additional features to an existing class without modifying it. This is possible by deriving a new class from the existing one. The new class will have the combined features of both the classes.

Q.17 The direct superclass of all the classes in java is

a) base class.

b) abstract class.

c) derive class.

d) object class.

Answer:

(d)

Explanation:

The class object is a direct superclass of all the classes in java, which are not explicitly declared as a subclass of another class.

Q. 18 In java, a class can inherit the property of its higher class, this property is known as

a) additive property.

b) transitive property.

c) transparent property.

d) visible property.

Answer:

(b)

Explanation:

The inheritance relation is transitive. Therefore, every class inherits state and behaviour (variable and methods) from all classes which are higher in the class hierarchy.

Q.19 Derive class

a) cannot be modified.

b) can be modified if its base class is modified.

c) cannot be modified if its base is modified.

d) can be modified.

Answer:

(d)

Explanation:

º Creating a new class from the base class is known as Derive Class.

º The member function and data member both can be modify in the derive class.

Q.20 If the superclass has a function with a same signature as in the subclass and you want to call the function of a superclass, then the keyword that can be used is

a) super.

b) abstract.

c) interface.

d) extends.

Answer:

(a)

Explanation:

You can refer to the superclass variable/function by using the keyword super.

CUET Information practice (IP) Chapter 6 Inheritance Set-B

Q.21 When the same name of variable and method comes in class, this property is known as

a) overloading.

b) overmethod.

c) overribbing.

d) overriding.

Answer:

(d)

Explanation:

A method in a subclass hides or overshadows a method inherited by the superclass if both methods have the same signature. This property is known as overriding.

Q.22 Java supports multiple inheritance in terms of

a) interface.

b) extends.

c) abstract.

d) multiple.

Answer:

(a)

Explanation:

º Java doesn’t support multiple inheritance.

º It uses the concept of interface.

º The aim of interface in java is to dictate common behaviour among the objects from diverse classes.

Q.23 The syntax to call the superclass variable if the superclass and subclass both have the same signature is

a) super.hidden Variable.

b) super.method Name.

c) sub.hidden Variable.

d) subr.Method.

Answer:

(a)

Explanation:

º You can refer to the superclass hidden variable by using the keyword super.

º The syntax is super.hidden Variable.

Q.24 The final variables are

a) static.

b) dynamic.

c) correct.

d) define.

Answer:

(a)

Explanation:

You may also declare variables to be final. This is not the same thing as declaring a method or class to be final. When a field is declared final, it is constant or static, i.e., which cannot be changed. It can be set once. Attempts to change it will generate either a compile-time error or an exception.

Q.25 A final subclass method cannot be

a) overriden.

b) overload.

c) interface.

d) abstract.

Answer:

(b)

Explanation:

To prevent a specific method from being overridden in a subclass, use the final modifier on the method declaration.

Q.26 A final class cannot be

a) overwritten.

b) overloaded.

c) extended.

d) superclass.

Answer:

(c)

Explanation:

º A final class cannot be extended.

º The compiler will not let you create a subclass that is declared final.

º String is a final class, i.e., we cannot extend.

Q.27 Final Variable, method, classes are used for

a) interface.

b) security.

c) abstract class.

d) class.

Answer:

(b)

Explanation:

Final variables, methods and classes are used for security. This is because Hackers extend some of your important classes and substitute their classes for the origin.

Q.28 Syntax for defining a variable as final is

a) public final <datatype>< nameof variable>=”variablevalue”.

b) public final <datatype>=” ”.

c) <datatype>< nameof variable>=” ”.

d)final < nameof variable><datatype>=” ”.

Answer:

(a)

Explanation:

º The syntax for defining a variable as final is

<public><final> <datatype>< nameof variable>=”value”.

º E.g., public final int var1 = 1;

Q.29 Here A is a superclass and B is a subclass. So, the correct syntax is

a) class A extends B { … }

b) class B extends A { … }

c) class A extends A { … }

d) class B extend A { … }

Answer:

(b)

Explanation:

º Here class B is a superclass and class A is a subclass.

º So, B is using all the data members and member functions which are declared in A.

º Extend is a keyword which is used by the subclass to recognize its superclass.

Q.30 Suppose there are two functions in the same scope, having same name. So, how would a complier recognize that which function has to call, according to the

a) function name.

b) function type.

c) function signature.

d) overriding.

Answer:

(a)

Explanation:

A function name having several definitions in the same scope that are differentiable by the number or types of their arguments is said to be an overloaded function.

Q.31 When a class inherits from a single base class, it is a

a) Single Inheritance.

b) Multilevel Inheritance.

c) Multiple Inheritance.

d) Hierarchical Inheritance.

Answer:

(a)

Explanation:

º When a subclass is derived simply from its parent class, then this mechanism is known as simple inheritance.

º In case of simple inheritance, there is only a subclass and its parent class.

º It is also called single inheritance or one level inheritance.

Q.32 When a class inherits from a multiple base class, it is

a) Single Inheritance.

b) Multilevel Inheritance.

c) Multiple Inheritance.

d) Hierarchical Inheritance

Answer:

(c)

Explanation:

In multiple inheritance, number of classes has inherited in a single class. Where two or more classes are known as base class and one is derive class.

Q.33 When several classes inherit from the same class, it is

a) Single Inheritance.

b) Multilevel Inheritance.

c) Multiple Inheritance.

d) Hierarchical Inheritance.

Answer:

(d)

Explanation:

When many subclasses inherit from a single base class, it is known as hierarchical inheritance.

Q.34 When a subclass is the base class of another class, it is a

a) Single Inheritance.

b) Multiple Inheritance.

c) Multilevel Inheritance.

d) Hierarchical Inheritance.

Answer:

(c)

Explanation:

When a subclass is derived from a derived class, then this mechanism is known as the multilevel inheritance. Multilevel inheritance can go up to any number of levels.

Q.35 The syntax to call the superclass method if the superclass and subclass both have the same signature is

a) super.hidden Variable.

b) super.methodname().

c) sub.hidden Variable.

d) subr.method.

Answer:

(a)

Explanation:

You can refer to the superclass method by using the keyword super. The syntax is super.methodname()

Q.36 The syntax for defining a method as final is

a) public final void < nameof method()>

b) public final <datatype>< nameof method()>

c) <datatype>< nameof variable>=””.

d)final < nameof variable><datatype>.

Answer:

(a)

Explanation:

º The syntax for defining a method as final is

Public final void < nameof method()>

º E.g., public final void convertCurrency()

Q.37 When a class inherits from multiple base classes and all of its base classes are subclasses of the same class, it is a

a) Hybrid Inheritance.

b) Multiple Inheritance.

c) Multilevel Inheritance.

d) Hierarchical Inheritance.

Answer:

(a)

Explanation:

When a subclass inherits from the multiple base classes and all its base classes inherit from a single base class, this form of inheritance is known as hybrid inheritance.

Q.38 The class which inherits the property of the other class is known as

a) Parent class.

b) Super class.

c) Sub class.

d) Class.

Answer:

(c)

Explanation:

º Creating a new class from the base class is known as Derive Class or Subclass. It can be changed.

Q.39 A class from which another class is inheriting its properties is called

a) Parent class.

b) Super class.

c) Sub class.

d) Class.

Answer:

b)

Explanation:

º A base class is also known as Super Class/ Parent Class.

º Basically, it is the existing class from which, new class can be derived.

Q.40 A feature accessible only inside their own class and nowhere else is known as

a) public member.

b) private member.

c) public protected.

d) protected.

Answer:

b)

Explanation:

Private – member is accessible only inside their own class.

Q.41 A feature accessible in all the classes whether a subclass or any other class in the same package or another package is known as

a) public member.

b) private member.

c) public protected.

d) protected.

Answer:

(a)

Explanation:

Public – member is accessible in all the classes whether derive or class is in the same package or class in another class along with their own class.

Q.42 A feature accessible inside all the classes in their own package as well as in all subclasses of their class are known as

a) public member.

b) private member.

c) public protected.

d) protected.

Answer:

(c)

Explanation:

Protected – member is accessible inside their own class, derive class regardless of whether derive class exists in the same package or any other package.

Q.43 The members which are defined without any specifiers are known as

a) public member.

b) private member.

c) default.

d) protected.

Answer:

(c)

Explanation:

The members declared without any specifiers are known as default members. They are accessible inside all the classes of the same package, i.e., their own package.

Q.44 The members are accessible only from to their subclasses are known as

a) protected.

b) private member.

c) default.

d) private protected.

Answer:

(d)

Explanation:

Private protected – members are accessible only from derive class (whether in the same package / other package).

Q.45 A method in a subclass hides or overshadows a method inherited from the superclass if both methods have the same signature. This is known as

a) overriding.

b) overloading.

c) inheritance.

d) class.

Answer:

(a)

Explanation:

The overriding method has the same name, number and type of parameters and return type as the method it overrides.

Q.46 Constructors of superclass are not inherited by

a) superclass.

b) parentclass.

c) class.

d) subclass.

Answer:

(d)

Explanation:

º Constructors are used to initialize the instance variables (fields) of an object.

º Constructors are similar to methods, but with some important differences.

º Constructor of superclass is not inherited by a subclass.

Q.47 An abstract class is created through keyword

a) overriding.

b) abstract.

c) interface.

d) overloading.

Answer:

b)

Explanation:

º These classes are used to declare common characteristics of subclasses.

º It can only be used as a superclass for other classes that extend the abstract class.

º An abstract class is created through the keyword abstract.

Q.48 An interface is declared with a keyword

a) overriding.

b) abstract.

c) interface.

d) overloading.

Answer:

(c)

Explanation: An interface can extend other an interface just like a class can extend a new class. A class can extend only one class, but interface can extend any number of interfaces.

Q. 49 A class can implement an interface using a keyword

a) implement.

b) abstract.

c) interface.

d) inheritance.

Answer:

(a)

Explanation: In java, the keyword “implement” specifies that the given class implements an interface. Keywords are basically reserved words which have a specific meaning relevant to a compiler.

Syntax: Here is the syntax for using the implement keyword in a class.

public class SquarePizza implements Pizza

{

/ write your code here

}

Q.50 An interface defines a

a) member.

b) variable.

c) protocol of behaviour.

d) document.

Answer:

(c)

Explanation:

º An interface defines a protocol of behaviour.

º It dictates common behaviour among objects from diverse class.

CUET Information practice (IP) Chapter 6 Inheritance Set-C

Q.51 An abstract class object is

a) not created.

b) created.

c) created in subclass.

d) created in superclass.

Answer:

(a)

Explanation:

An abstract class is the one that represents merely a concept and whose objects cannot be created.

Q.52 A superclass variable hides, when superclass variable and subclass variable have there

a) name.

b) no name.

c) same name.

d) definition.

Answer:

(c)

Explanation:

A variable or data member in a subclass having a same name as that of an inherited data member hides the inherited member. This is called hiding member.

Q.53 A superclass method overrides when a superclass & a subclass method have

a) same name.

b) same signature.

c) different name.

d) definition.

Answer:

(b)

Explanation:

An overridden method or hidden variable can be accessed using the keyword super as in super.methodname() or super.variablename.

Q.54 A keyword use to define an object in java is

a) newer.

b) new1.

c) basenew.

d) new.

Answer:

(d)

Explanation:

New keyword allocates the memory for the object.

Q.55 super.overriddenMethod(); it will call the

a) superclass function.

b) subclass function.

c) overloading function.

d) variable.

Answer:

(c)

Explanation:

º It will call the method of the parent class.

º It is used when the superclass and subclass have the same function.

º Super keyword is used to call immediate parent.

Q.56 Syntax for allocating the memory to the object is

a) <objname> = new <classname();

b) <classname> = new <classname();

c) <classname> <objname> = new <classname();

d) <classname> <objname> = new

Answer:

c)

Explanation:

º It allocates the memory for the object.

º Syntax for creating an object is

<classname> <objname> = new <classname();

Q.57 An object can refer to itself by using

a) super keyword.

b) interface keyword.

c) this keyword.

d) sub keyword.

Answer:

(b)

Explanation:

Interface keyword refers to the current object.

Q. 58 Way to make general classes into more specific classes is known as

a) overriding.

b) inheritance.

c) overloading.

d) class.

Answer:

b)

Explanation:

Inheritance allows new classes to be built from older and less specialized classes instead of being rewritten from scratch.

Q.59 The syntax for implementing the interface in the class is

a) class <classname> implements {…}

b) <classname> implements <interface_1>,<interface_2>{…}

c) class <classname> implements <interface_1>, <interface_2> {…}

d) class <classname> <interface_1>,<interface_2>{…}

Answer:

(c)

Explanation:

A class can implement more than one interface using keyword implements in the class declaration followed by the comma-separated list of interface name like

class<classname>implements<interface_1>,<interface_2>{ }

Q.60 In java, super keyword is used to

a) call immediate parent, all the constructor of parent class.

b) call all the constructor of child class.

c) call immediate child.

d) call immediate child, all the constructor of child class.

Answer:

(a)

Explanation:

The important points of super keyword in Java are:

1. Super keyword is used to call immediate parent.

2. Super keyword can be used with instance members, i.e., instance variables and instance methods.

3. Super keyword can be used within constructor to call the constructor of parent class.

Q.61 A concrete superclass is the one whose objects can be/cannot be

a) declared & created.

b) declared.

c) created.

d) declared & created.

Answer:

(a)

Explanation:

A concrete superclass is the one whose objects can be declared and created. Sometimes, we need to define a superclass having general characteristics and behaviour of its subclasses, but no object of such class should be defined as the class depicts a concept only.

Q.62 The syntax for the abstract class is

a) public abstract {….}.

b) public <classname>{….}.

c) public abstract <classname>{….}.

d) public implement <classname>{….}.

Answer:

(c)

Explanation:

º An abstract class is the one that simply represents a concept and whose objects cannot be created. It is created through the use of keyword abstract.

º The syntax for defining the abstract class is

public abstract <classname>{…}.

Q.63 Syntax for defining the abstract method is

a) public abstract void <methodname();>

b) public void <methodname();>

c) public abstract void ();

d) public <methodname();>

Answer:

(a)

Explanation:

º While the time of defining the abstract method, one has to use the keyword abstract.

º So, the correct syntax for defining abstract method is

public abstract void <methodname();>

e.g., public abstract void getvalue();

Q.64 The feature which we use to control the access of the data member and member function is known as

a) Access specifier.

b) Controllers.

c) Limits.

d) Control specifier.

Answer:

(a)

Explanation:

An access specifier controls access of class members and variables by other objects. The various types of access specifiers in Java are private, public, protected, public protected etc.

Q.65 The syntax for defining the interface is

a) implement interfacename{…}.

b) interface interfacename{…}.

c) interfacename{…}.

d) class interfacename{…}.

Answer:

(b)

Explanation:

The currency data type should be used to prevent rounding off during calculations. It is accurate to 15 digits to the left of decimal point and 4 digits to the right. Also currency amounts do not suffer from rounding errors as the single and double numeric types can.

Q.66 While the time of defining the interface, you need to replace the keyword class with

a) abstract.

b) implement.

c) final.

d) interface.

Answer:

(d)

Explanation:

The definition of interface is similar to the definition of classes. You just need to replace the keyword class with another keyword interface.

Q.67 Abstract method has to declare with the modifier

a) private.

b) private protected.

c) protected.

d) public.

Answer:

(d)

Explanation:

º Abstract method with an empty body (only the signature of the methods is declared).

º These methods have to be declared with the modifier public as they are used by the other class also.

Q.68 The modifier which we cannot change should be declared as

a) private.

b) public static final.

c) default.

d) public.

Answer:

(b)

Explanation:

Variable which cannot be modified; they have to be declared with the modifier public static final.

Q.69 The interface body contains two things which are

a) abstract method and constants.

b) abstract method and default variables.

c) only constants.

d) only abstract method.

Answer:

(a)

Explanation:

º The interface body can only declare two things:

o Abstract methods: Methods with an empty body. These methods have to declare as modifier public.

o Constants: Variables which cannot be modified; they have to be declared with the modifier public static final.

Q.70 An interface can extend

a) one interface.

b) two interfaces.

c) three interfaces.

d) many interfaces.

Answer:

(d)

Explanation:

An interface can extend other interfaces, just as a class can extend another class. However, a class can extend only one class, but an interface can extend any number of interfaces.

Q.71 To prevent the class from being inherited, we use keyword

a) abstract.

b) final.

c) interface.

d) local.

Answer:

(b)

Explanation:

º To prevent a class from being inherited, we declare it as final.

º A final class cannot be extended.