Chapter 10: Inheritance (True or False)

Ace your homework & exams now with Quizwiz!

If a superclass does not have a default constructor and does not have a no-arg constructor, then the class that inherits from it automatically creates a no-arg constructor for the superclass

false

In an inheritance relationship, the superclass constructor always executes after the subclass constructor.

false

In order for a subclass method to override a superclass method, it must have the same name, but may have different parameters

false

In order for the subclass to inherit fields and methods from the superclass, they need to be overridden.

false

Is a subclass overrides a method, the associated superclass must now call the new version of the method

false

Members with package access can also access subclasses that are in a different package

false

Superclass constructors are inherited

false

You can use the 'super' statement to call the superclass constructor in any methods in the subclass.

false

A subclass inherits all of the public members of its superclass, as well any higher level superclasses

true

A subclass may call an overridden superclass method by prefixing its name with the 'super' keyword and a dot ( . )

true

Even though a subclass may override a method in the superclass, superclass objects still call the superclass version of the method

true

Every class in Java, including the ones in the API and the classes that you create, directly or indirectly inherits from a class named 'Object', which is part of the 'java.lang' package.

true

If a subclass constructor does not explicitly call a superclass constructor, Java will automatically call the superclass's default constructor, or no-arg constructor

true

If a superclass does not have a default constructor and does not have a no-arg constructor, then the class that inherits from it must call one of the constructors that the superclass does have. If it does not, an error will result.

true

If you do not provide an access specifier for a class member, the class member is given package access by default. This means that any method in the same package may access the member.

true

In an inheritance relationship, the superclass constructor always executes before the subclass constructor.

true

In order for a subclass method to override a superclass method, it must have the same signature

true

New fields and methods may be added to a subclass, and that is what makes it a specialized version of the superclass.

true

The 'super' statement that calls the superclass constructor must be the first statement in the subclass's constructor.

true

The subclass inherits fields and methods from the superclass without any of them having to be rewritten.

true

Protected members may be accessed by methods in the same package or subclass. This is true even if the subclass is in a different package.

true

Superclass constructors are not inherited

true

The 'super' statement that calls the superclass constructor may be written only in the subclass's constructor. You cannot call the superclass constructor from any other method.

true

When a method overrides another method, they both have the same signature

true

When an object of the subclass is created, the private members of the superclass exist in memory, but only methods in the superclass can access them.

true

Every class in Java, including the ones in the API and the classes that you create, directly or indirectly inherit from a class names 'Java', which is part of the 'java.lang' package

false

When creating a subclass, the keyword 'extends' is written after the subclass name, but before the superclass name. Example: 'public class Exam extends GradedActivity'

true

When an object of the subclass is created, the private members of the superclass exist in memory, and are only able to be access by its immediate subclass

false

When creating a subclass, the keyword 'extends' is written before both the subclass and superclass names. Example: 'public class extends Exam GradedActivity'

false

While the subclass inherits all of the methods and fields from the superclass, it is only able to make new methods in the subclass if the superclass is abstract

false

A method can override another method in the same class

false

A subclass inherits all of the public members of its superclass, but not any members from higher level superclasses

false

If a subclass constructor does not explicitly call a superclass constructor an error will always occur.

false

A method in a subclass can overload a method in a superclass

true

start again on page 664

:)

The 'super' statement that calls the superclass constructor must be the last statement in the subclass's constructor.

false

If you do not provide an access specifier for a class member, the class member is given private access by default.

false


Related study sets

Unit 1 - Comparing and Contrasting

View Set

Targeted Medical-Surgical: Endocrine

View Set

advanced nursing final Keiser University

View Set

ACG 2071 EXAM 3 PRACTICE QUESTIONS

View Set

NUR 221 PrepU Psychiatric and Mental Health Nursing.

View Set

XCEL FINAL EXAM MISSED QUESTIONS

View Set