Chapter 10 Inheritance

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

A program uses two classes: Animal and Dog. Which class is the superclass and which is the subclass?

Animal Super, Dog subclass

What is an abstract method?

Makes sure method is implementing by override.

Can a subclass ever directly access the private members of its superclass?

No

All classes directly or indirectly inherit from this class.

Object

The superclass constructor always executes before the subclass constructor.

True

When a class contains an abstract method, the class cannot be instantiated.

True

In a subclass constructor, a call to the superclass constructor must __________ .

appear as the very first statement

This operator can be used to determine whether a reference variable references an object of a particular class.

instanceof

A subclass does not have access to these superclass members.

private

Reference variables can be polymorphic. What does this mean?

morph into a reference of object or interface.

What is an abstract class?

generic and other classes inherit from it.

When you instantiate an anonymous inner class, the class must do one of two things. What are they?

implement an interface or extend superclass

What are the differences between an abstract class and an interface?

interface specifies behavior and abstract class is generic.

What is a functional interface?

interface that has one abstract method.

What is an "is-a" relationship?

is a relationship not a has a relationship

A class may only implement one interface.

False

A subclass reference variable can reference an object of the superclass.

False

A superclass has a member with package access. A class that is outside the superclass's package but inherits from the superclass can access the member.

False

An object of a superclass can access members declared in a subclass.

False

If a subclass constructor does not explicitly call a superclass constructor, Java will not call any of the superclass's constructors.

False

When a method is declared with the final modifier, it must be overridden in a subclass.

False

When does dynamic binding take place?

Run time

Which constructor is called first, that of the subclass or the superclass?

SuperClass

A superclass reference variable can reference an object of a subclass that extends the superclass.

True

By default all members of an interface are public.

True

Constructors are not inherited.

True

In a subclass, a call to the superclass constructor can only be written in the subclass constructor.

True

Making an instance of one class a field in another class is called ___________.

aggregation

Abstract classes cannot __________ .

be instantiated

Fields in an interface are __________ .

both final and static

This is a method that is automatically called when an instance of a class is created.

constructor

What is a lambda expression?

creates object that implements functional interface.

With this type of binding, the Java Virtual Machine determines at runtime which method to call, depending on the type of the object that a variable references.

dynamic

This key word indicates that a class inherits from another class.

extends

A method in a subclass having the same name as a method in the superclass but a dif-ferent signature is an example of __________ .

overloading

Abstract methods must be __________ .

overridden

A method in a subclass that has the same signature as a method in the superclass is an example of __________ .

overriding

What is the difference between overriding a superclass method and overloading a superclass method?

parameters. rewrite.

What is the superclass and what is the subclass in the following line? public class Pet extends Dog

pet is subclass, dog is superclass

These superclass members are accessible to subclasses and classes in the same pack-age.

protected

What is the difference between a protected class member and a private class member?

protected in same package and kids. private only parent.

When a class implements an interface, it must __________ .

provide all of the methods that are listed in the interface, with the exact signatures and return types specified

In an inheritance relationship, this is the specialized class.

subclass

This key word refers to an object's superclass.

super

The following is an explicit call to the superclass's default constructor.

super();

In an inheritance relationship, this is the general class.

superclass


संबंधित स्टडी सेट्स

ESP.FRA🔸 S/08 Los colores y formas | 27

View Set

Chapter 8(inquizitive) Political Participation and Voting

View Set

CIS 150 Exam 1-1: Computer Concepts/Hardware/Software

View Set

Administrative Assisting Study Guide

View Set