Inheritance Test

Ace your homework & exams now with Quizwiz!

A "has-a" relationship represents associations. In a "has-a" relationship, a class object should contain references to objects of other classes.

true

A subclass can explicitly invoke a constructor of its superclass by using keyword super, followed by a set of parentheses containing the superclass constructor arguments.

true

A subclass cannot access or inherit the private members of its superclass. Allowing this would violate the encapsulation of the superclass. A subclass can, however, inherit the non-private members of its superclass.

true

A subclass is more specific than its superclass and represents a smaller group of objects.

true

A superclass method can be overridden in a subclass to declare an appropriate implementation for the subclass.

true

A superclass's private members are accessible only within the declaration of that superclass.

true

A superclass's protected members have an intermediate level of protection between public and private access. They can be accessed by members of the superclass, by members of its subclasses and by members of other classes in the same package.

true

A superclass's public members are accessible wherever the program has a reference to an object of that superclass or one of its subclasses.

true

An "is-a" relationship represents inheritance. In an "is-a" relationship, an object of a subclass also can be treated as an object of its superclass.

true

Every object of a subclass is also an object of that class's superclass. However, a superclass object is not an object of its class's subclasses.

true

In single inheritance, a class is derived from one direct superclass. In multiple inheritance, a class is derived from more than one direct superclass. Java does not support multiple inheritance.

true

Method toString takes no arguments and returns a String. The Object class's toString method is normally overridden by a subclass

true

The first task of any subclass constructor is to call its direct superclass's constructor, either explicitly or implicitly, to ensure that the instance variables inherited from the superclass are initialized properly.

true

True or false? The direct superclass of a subclass (specified by the keyword extends in the first line of a class declaration) is the superclass from which the subclass inherits. An indirect superclass of a subclass is two or more levels up the class hierarchy from that subclass.

true

When a subclass method overrides a superclass method, the superclass method can be accessed from the subclass if the superclass method name is preceded by the keyword super and a dot (.) separator

true

When an object is output using the System.out.println method or an object is added to a string using the operator +, the object's toString method is called implicitly to obtain its string representation.

true


Related study sets

anatomy lecture final study guide

View Set

ATI Ch. 20 Cardiovascular Disorders Questions

View Set

Chapter 12: DNA: The Carrier of Genetic Information

View Set

Econ 2300 Kennesaw State Chap 1 & 2

View Set

Chapter 17: Mood Disorders and Suicide

View Set

Окружающий мир 3 класс.Биология (119) карточки

View Set

Evidence topic 3: Presumption of Innocence

View Set

- positive/negative reinforcement/punishment

View Set