QUESTION 12 A subclass inherits all its data members from the superclass; it has
ID: 3913319 • Letter: Q
Question
QUESTION 12
A subclass inherits all its data members from the superclass; it has none of its own.
True
False
QUESTION 13
Java uses late binding for methods that are private but not for methods that are marked final.
True
False
QUESTION 14
Using the mechanism of inheritance, every public member of the class Object can be overridden and/or invoked by every object of any class type.
True
False
QUESTION 15
In Java, a reference variable of a superclass type cannot point to an object of its subclass.
True
False
QUESTION 16
An abstract class can only contain abstract methods.
True
False
QUESTION 17
The class Object is directly or indirectly the superclass of every class in Java.
True
False
QUESTION 18
In Java, you can automatically make a reference variable of a subclass type point to an object of its superclass.
True
False
QUESTION 19
A subclass can have its own private data members, but a subclass cannot have its own constructors.
True
False
QUESTION 20
Suppose that the class Mystery is derived from the class Secret. The following statements are legal in Java.
Secret secRef;
Mystery mysRef = new Mystery();
secRef = mysRef;
True
False
QUESTION 21
Redefining a method of a superclass is also known as overloading a method.
True
False
QUESTION 22
The subclass can override public methods of a superclass.
True
False
QUESTION 23
Composition is a ‘‘is-a’’ relation.
True
False
QUESTION 24
The superclass inherits all its properties from the subclass.
True
False
QUESTION 25
An abstract method is a method that has only the heading with no body.
True
False
QUESTION 26
Every Java class (built-in or user-defined) automatically includes the method toString.
True
False
QUESTION 27
Composition is a “has-a” relation.
True
False
QUESTION 28
To override a public method of a superclass in a subclass, the corresponding method in the subclass must have the same name but a different number of parameters.
True
False
QUESTION 29
You can instantiate an object of a subclass of an abstract class, but only if the subclass gives the definitions of all the abstract methods of the superclass.
True
False
Inheritance implies an “is-a” relationship.
True
False
QUESTION 31
The private members of a superclass can be accessed by a subclass.
True
False
QUESTION 32
In Java, extends is a reserved word.
True
False
QUESTION 33
A call to the default constructor of a superclass must be the first statement in a constructor.
True
False
QUESTION 34
Inheritance implies an ‘‘has-a’’ relationship.
True
False
Explanation / Answer
QUESTION 12
A subclass inherits all its data members from the superclass; it has none of its own.
False
Explanation: A subclass inherits all the members (fields, methods, and nested classes) from its superclass. But it can have its own data memmbers
QUESTION 13
Java uses late binding for methods that are private but not for methods that are marked final.
False
Explanation: private, final and static members (methods and variables) use static binding while for virtual methods (In Java methods are virtual by default) binding is done during run time based upon run time object.
QUESTION 14
Using the mechanism of inheritance, every public member of the class Object can be overridden and/or invoked by every object of any class type.
False
Explanation: only methods are overidden, as class Object is base class for all, its public member can be invoked from ant class but only public member can be overidden.
QUESTION 15
In Java, a reference variable of a superclass type cannot point to an object of its subclass.
False
Expanation: The reference variable of the Parent class is capable to hold its object reference as well as its child object reference.
QUESTION 16
An abstract class can only contain abstract methods.
False
Explanation: An abstract class is a class that is declared abstract—it may or may not include abstract methods.
QUESTION 17
The class Object is directly or indirectly the superclass of every class in Java.
True
QUESTION 18
In Java, you can automatically make a reference variable of a subclass type point to an object of its superclass.
False
Explanation: When a subclass extends a superclass, it can also have additional attributes
and methods not existing in the superclass.
QUESTION 19
A subclass can have its own private data members, but a subclass cannot have its own constructors.
False
Explanation: A subclass can have its own constructor
QUESTION 20
Suppose that the class Mystery is derived from the class Secret. The following statements are legal in Java.
Secret secRef;
Mystery mysRef = new Mystery();
secRef = mysRef;
True
Explanation: The reference variable of the Parent class is capable to hold its object reference as well as its child object reference.
QUESTION 21
Redefining a method of a superclass is also known as overloading a method.
False
Explanation: Redefining a method of a superclass is also known as overriding a method.
QUESTION 22
The subclass can override public methods of a superclass.
True
QUESTION 23
Composition is a ‘‘is-a’’ relation.
False
Explanation: Composition is a "part-of" relationship.
QUESTION 24
The superclass inherits all its properties from the subclass.
False
Explanation: The subclass inherits all its properties from the superclass.
QUESTION 25
An abstract method is a method that has only the heading with no body.
True
Explanation: An abstract method is a method that is declared without an implementation (without braces, and followed by a semicolon)
QUESTION 26
Every Java class (built-in or user-defined) automatically includes the method toString.
True
Explanation: Every class in java is child of Object class either directly or indirectly. Object class contains toString() method.
QUESTION 27
Composition is a “has-a” relation.
False
Explanation: Composition is a "part-of" relationship.
QUESTION 28
To override a public method of a superclass in a subclass, the corresponding method in the subclass must have the same name but a different number of parameters.
False
Explanation: For overriding a superclass method, subclass must define method with same name and same paraeters.
QUESTION 29
You can instantiate an object of a subclass of an abstract class, but only if the subclass gives the definitions of all the abstract methods of the superclass.
True
Explanation: A class derived from the abstract class must implement all those methods that are declared as abstract in the parent class.
QUESTION 30
Inheritance implies an “is-a” relationship.
True
QUESTION 31
The private members of a superclass can be accessed by a subclass.
False
Explanation: private members of a superclass can not be accessed by a subclass
QUESTION 32
In Java, extends is a reserved word.
True
QUESTION 33
A call to the default constructor of a superclass must be the first statement in a constructor.
False
Explanation: If the subclass constructor does not specify which superclass constructor to invoke then the compiler will automatically call the accessible no-args constructor in the superclass.
QUESTION 34
Inheritance implies an ‘‘has-a’’ relationship.
False
Explanation: Association is a “has-a” type relationship
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.