Quiz3

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

Which of the following is true? A class may inherit from a superclass or implement an interface, but not both. A class may implement at most one interface. A class may implement any number of interfaces. One class may inherit from multiple superclasses.

A class may implement any number of interfaces.

Which of the following is true of superclass constructors? a) A superclass constructor is always called before the subclass constructor. b) A subclass constructor is always called before the superclass constructor. The "super" keyword may be used to explicitly call a superclass constructor from the subclass. c)The "sub" keyword may be used to explicitly call a subclass constructor from the superclass. d)It is not possible to explicitly call a superclass constructor from the subclass

A superclass constructor is always called before the subclass constructor. The "sub" keyword may be used to explicitly call a subclass constructor from the superclass. It is not possible to explicitly call a superclass constructor from the subclass.

Which of the following is true? Abstract classes don't have constructors, because they cannot be instantiated. Abstract classes may have constructors, even though they cannot be instantiated. Abstract classes have abstract constructors.

Abstract classes may have constructors, even though they cannot be instantiated.

Assume that class A does not define a toString method, and does not explicitly extend any other class. What will happen if we call toString on an object of class A?

All classes implicitly inherit from Object, so the toString method defined by Object will be called

Which of the following best describes an interface in Java? An interface is similar to an abstract class that has only abstract methods. An interface is a specialized class used to connect two other classes. Interface is the default access specifier. It applies whenever an instance variable or method is NOT declared to be public, private or protected. The interface keyword is used to indicate that one class is a subclass of another.

An interface is similar to an abstract class that has only abstract methods.

A method must always catch any exception that is raised when that method is executed. T/F

F

What is the purpose of the throws keyword?

It informs the compiler that the method may throw the indicated exception type

What is the role of the protected keyword in Java?

It is an access specifier that provides a level of access somewhere between public and private.

Assuming that A is an interface, which of the following is true? It is possible to instantiate an object of type A. It is possible to declare a variable of type A. Both are true. Neither are true.

It is possible to declare a variable of type A.

T/F abstract classes may include both abstract and non-abstract methods

T

How do we indicate in a UML diagram that a class is abstract?

The name is in italics

Which of the following is true? The superclass inherits, and may access, all public members of the subclass, except the constructor. The subclass inherits, and may access, all public members of the superclass, except the constructor. The superclass inherits, and may access, all members (public and private) of the subclass, except the constructor. The subclass inherits, and may access, all members (public and private) of the superclass, except the constructor.

The subclass inherits, and may access, all public members of the superclass, except the constructor.

Which of the following accurately describe the relationship between a subclass and a superclass. There is an "is a" relationship between the subclass and the superclass. An instance of the subclass "is a" instance of the superclass as well. The subclass is a specialized version of the superclass. The superclass is a specialized version of the subclass. There is an "is a" relationship between the superclass and the subclass. An instance of the superclass "is a" instance of the subclass as well.

The subclass is a specialized version of the superclass.

Which of the following statements is true? a) A reference variable may only hold an object reference if there is an exact match between the type of the object and the type of the variable. b) A reference variable my hold object references of non-matching types, as long as the object type is a subclass of the variable type. c) A reference variable my hold object references of non-matching types, as long as the object type is a superclass of the variable type. d) A reference variable my hold object references of any reference type, though a cast may be required.

b) A reference variable my hold object references of non-matching types, as long as the object type is a subclass of the variable type.

Which of the following best describes the difference between overloading and overriding a method? a) There is no difference. They mean the same thing. b) When one method overrides another, both methods will have the same signature. c) When one method overloads another, both methods will have the same signature. d) Overloading only makes sense in the context of inheritance.

b) When one method overrides another, both methods will have the same signature.

Which of the following is described as "dynamic binding"? a) The contents of variables may change dynamically at run-time. b) An object may dynamically change its superclass at run-time. c) The JVM dynamically determines which method to call based on the object's type at run-time. d) The JVM dynamically determines which method to call based on the variable's type at run-time.

c) The JVM dynamically determines which method to call based on the object's type at run-time.

In a try ... catch ... finally statement,

the finally block is always executed

Which of the following Java keywords are most closely related to exception handling? attempt, except try, catch static, final first, last

try, catch


Set pelajaran terkait

Chapter 13: Tectonics, Earthquakes, and Volcanism

View Set

HA PrepU Chapter 2- Critical Thinking in HA

View Set

SFDC - Sales and Marketing Applications

View Set

How to make text bold on Quizlet

View Set

Arkansas Ag Mechanics Unit 7: Graphics

View Set