Chapter 10

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

In the following statement, which is the superclass? public class ClassA extends ClassB implements ClassC

ClassB

Given the following code, which statement is true? public class ClassB implements ClassA{ }

ClassB must override each method in ClassA.

If ClassC is derived from ClassB which is derived from ClassA, this would be an example of ________.

a chain of inheritance

What type of relationship exists between two objects when one object is a specialized version of another object?

"is a"

Protected class members can be denoted in a UML diagram with the ________ symbol.

#

Which key word indicates that a class inherits from another class?

extends

When a method is declared with the ________ modifier, it cannot be overridden in a subclass.

final

In the following statement, which is the interface? public class ClassA extends ClassB implements ClassC

ClassC

What is wrong with the following code? public class ClassB extends ClassA { public ClassB() { int init = 10; super(40); } }

The call to the method super must be the first statement in the constructor.

In ________, inheritance is shown with a line that has an open arrowhead at one end that points to the superclass.

a UML diagram

A(n) ________ method is a method that appears in a superclass but expects to be overridden in a subclass.

abstract

Replacing inadequate superclass methods with more suitable subclass methods is known as ________.

method overriding

In Java, a reference variable is ________ because it can reference objects of types different from its own, as long as those types are related to its type through inheritance.

polymorphic

When declaring class data members it is best to declare them as ________.

private members

Which of the following statements correctly specifies two interfaces?

public class ClassA implements Interface1, Interface2

Which of the following statements declares Salaried as a subclass of PayType? public class Salaried extends PayType public class Salaried implements PayType public class PayType derives Salaried public class Salaried derivedFrom(PayType)

public class Salaried extends PayType

If a class contains an abstract method ________.

the method will only have a header, but not a body, and will end with a semicolon

If two methods have the same name but different signatures they are ________.

overloaded

In the following statement, which is the subclass? public class ClassA extends ClassB implements ClassC

ClassA

n the following code, what is missing from ClassA? Line 1 public interface MyInterface Line 2 { Line 3 int FIELDA = 55; Line 4 public int methodA(double); Line 5 } Line 6 public class ClassA implements MyInterface Line 7 { Line 8 FIELDA = 60; Line 9 public int methodB(double) { } Line 10 }

It does not override methodA.

In the following code, what will the call to super do? public class ClassB extends ClassA { public ClassB() { super(40); System.out.println("This is the last statement "+"in the constructor."); } }

It will call the constructor of ClassA that receives an integer as an argument.

In the following code, which line has an error? Line 1 public interface Interface1 Line 2 { Line 3 int FIELDA = 55; Line 4 public int methodA(double){} Line 5 }

Line 4

In the following code, which line in ClassA has an error? Line 1 public interface MyInterface Line 2 { Line 3 int FIELDA = 55; Line 4 public int methodA(double); Line 5 } Line 6 public class ClassA implements MyInterface Line 7 { Line 8 FIELDA = 60; Line 9 public int methodA(double) { } Line 10 }

Line 8 (all fields in an interface are final and static)

Which of the following is true about protected access?

Protected members may be accessed by methods in the same package or in a subclass, even when the subclass is in a different package.

A class becomes abstract when you place the ________ key word in the class definition.

abstract

Which of the following is the operator used to determine whether an object is an instance of a particular class?

instanceOf

If a method in a subclass has the same signature as a method in the superclass, the subclass method ________ the superclass method.

overrides


Ensembles d'études connexes

International Health Regulations

View Set

Chapter 6 Review - The American Revolution

View Set

Personal Finance, Unit 5.0 - 5.03

View Set

Biology - Unit 1a: Lactase Persistence

View Set