Unit 10 Reviewing the Basics Quiz

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Two of the following statements are true, and one is false. Identify the false statement:

a. If a data field is defined as protected, a method in a child class can use it directly. ***b. A subclass inherits all the data and methods of its superclass, except the private ones.** c. Information hiding describes the concept of keeping data private.

Two of the following statements are true, and one is false. Identify the false statement:

a. Subclasses are more specific than the superclass they extend. b. A derived class has access to all its parents' nonprivate methods. **c. You use the keyword inherits to achieve inheritance in Java.**

Two of the following statements are true, and one is false. Identify the false statement:

a. When a superclass contains only nondefault constructors, you must include at least one constructor for each subclass you create. b. When constructors initialize variables, you usually want the superclass constructor to initialize the data fields that originate in the superclass and the subclass constructor to initialize the data fields that are specific to the subclass. **c. When you create any subclass object, the subclass constructor executes first, and then the superclass constructor executes.**

Two of the following statements are true, and one is false. Identify the false statement:

a. When you use inheritance, you save time and reduce errors. *b. A class that is used as a basis for inheritance is called a subclass.*** c. When you use inheritance in Java, you can create a new class that contains all the data and methods of an existing class

Two of the following statements are true, and one is false. Identify the false statement:

a. You can use the keyword super within a method in a derived class to access a method in a base class that has not been overridden. b. You can use the keyword super within a method in a derived class to access an overridden method in a base class. **c. You can use the keyword this within a method in a derived class to access an overridden method in a base class.**

If you create a data field or method that is ____________, it can be used within its own class or in any classes extended from that class.

a. both public and protected

When a parent class contains a static method, child classes ____________ override it.

a. cannot

When a subclass method has the same name and argument types as a superclass method, the subclass method ____________ the superclass method.

a. overrides

Which of the following statements is true?

b. A child class inherits from a parent class.

Two of the following statements are true, and one is false. Identify the false statement:

a. A subclass cannot override methods that are declared final in the superclass. ***b. A subclass cannot override methods that are declared private in the superclass.*** c. A subclass cannot override methods that are declared static in the superclass.

Two of the following statements are true, and one is false. Identify the false statement:

a. Any child class object has all the attributes of its parent, but all of those attributes might not be directly accessible. **b. You override a parent class method by creating a child class method with the same identifier but a different parameter list or return type.** c. When a child class method overrides a parent class method, and you use the method name with a child class object, the child class method version executes.

If the only constructor in a superclass requires arguments, its subclass ____________.c. must contain a constructor

c. must contain a constructor

A reliable way to discover which of two classes is the base class and which is the subclass is to ____________.

c. try saying the two class names together

A class named Building has a public, nonstatic method named getFloors(). If School is a child class of Building, and modelHigh is an object of type School, which of the following statements is valid?

d. modelHigh.getFloors();

When you instantiate an object that is a member of a subclass, the ____________ constructor executes first.

d. parent class

A child class Motorcycle extends a parent class Vehicle. Each class constructor requires one String argument. The Motorcycle class constructor can call the Vehicle class constructor with the statement ____________.

d. super("Suzuki");

Within a subclass, you cannot override ____________ methods.

static

The Java keyword that creates inheritance is inherits .

False

Which of the following choices is the best example of a parent class/child class relationship?

d. BodyOfWater/River

You call a static method using the name of ____________, a dot, and the method name.

d. either its class or the class's superclass

Employing inheritance reduces errors because ____________.

d. many of the methods a subclass needs have already been used and tested

If a superclass constructor requires arguments, any constructor of its subclasses must call the superclass constructor as the last statement.

false

In Java, the concept of keeping data private is known as polymorphism.

false

You use a ____________ method access specifier when you create methods for which you want to prevent overriding in extended classes.

final

A base class can also be called a superclass.

true

A compiler can decide to inline a final method—that is, determine the code of the method call when the program is compiled.

true

The keyword super always refers to the parent class of the class in which you use it.

true


Set pelajaran terkait

Hands-On Ethical Hacking and Network Defense, Chapter 5

View Set

Chapter 22: Nursing Management of the Postpartum Woman at Risk (Prep U)

View Set

Path 63 Renal BV Disorders - Renal Cell Carcinoma

View Set

Chapter 12: Marketing Channels: Delivering Customer Values

View Set