Section 1

Preview this deck

Question 11 Overriding a method differs from overloading a method because ________. Selected Answer:

Front

Star 0%
Star 0%
Star 0%
Star 0%
Star 0%

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Active users

0

All-time users

0

Favorites

0

Last updated

6 years ago

Date created

Mar 1, 2020

Cards (71)

Section 1

(50 cards)

Question 11 Overriding a method differs from overloading a method because ________. Selected Answer:

Front

overridden methods have the same signature

Back

Question 15

Front

Which of the following is false? Selected Answer: A static method can call instance methods directly.

Back

Question 10 Which statement is false? Selected Answer:

Front

Clients are usually involved in a class's implementation.

Back

Question 16

Front

When must a program explicitly use the this reference? Selected Answer: Accessing an instance variable that is shadowed by a local variable.

Back

Question 8 Set methods are also commonly called ________ methods and get methods are also commonly called ________ methods. Selected Answer:

Front

mutator, accessor

Back

Question 11 A programmer-defined constructor that has no arguments is called a(n) ________. Selected Answer:

Front

no-argument constructor

Back

Question 9 Which statement is false? Selected Answer:

Front

The compiler always creates a default constructor for a class.

Back

Question 26 A final field should also be declared ________ if it is initialized in its declaration. Selected Answer: static

Front

Back

Question 16

Front

To avoid duplicating code, use ________, rather than ________. Selected Answer: inheritance, the "copy-and-paste" approach

Back

Question 24 Static class variables ________. Selected Answer:

Front

are shared by all objects of a class

Back

Question 15 When overriding a superclass method and calling the superclass version from the subclass method, failure to prefix the superclass method name with the keyword super and a dot (.) in the superclass method call causes ________. Selected Answer:

Front

infinite recursion

Back

Question 13 Which syntax imports all static members of class Math? Selected Answer:

Front

import static java.lang.Math.*.

Back

Ch. 8 Test Bank

Front

Back

Question 17

Front

Using public set methods helps provide data integrity if ________. Selected Answer: Both the instance variables are private and the methods perform validity checking.

Back

Question 21 The default equals implementation of class Object determines ________. Selected Answer:

Front

whether two references refer to the same object in memory

Back

Question 6 BigDecimal gives you control over how values are rounded. By default ________. Selected Answer:

Front

all calculations are exact and no rounding occurs

Back

Question 2 private fields of a superclass can be accessed in a subclass ________. Selected Answer:

Front

by calling public or protected methods declared in the superclass

Back

Question 18 Which of the following statements is false? Selected Answer:

Front

A superclass object is a subclass object.

Back

Question 25 Which of the following is false? Selected Answer:

Front

Objects are marked for garbage collection by method finalize. Response Feedback: Objects are marked for garbage collection when there are no more references to the object.

Back

Question 17 Using the protected keyword also gives a member ________. Selected Answer:

Front

package access

Back

Question 18

Front

Which statement is false? Selected Answer: An enum constructor cannot be overloaded.

Back

Which of the statements below is false? Selected Answer:

Front

A reference of type A can be treated as a reference of type B.

Back

Question 3 Which method changes the text the label displays? Selected Answer:

Front

setText

Back

Question 5

Front

Which of the following is the superclass constructor call syntax? Selected Answer: keyword super, followed by a set of parentheses containing the superclass constructor arguments

Back

Question 3

Front

Which of the following class members should usually be private? Selected Answer: Variables (or fields)

Back

Question 9 Superclass methods with this level of access cannot be called from subclasses. Selected Answer:

Front

private

Back

Question 6 The default implementation of method clone of Object performs a ________. Selected Answer:

Front

shallow copy

Back

Question 12

Front

Which of the following statements is false? Selected Answer: Use the access modifier package to give a method or variable package access.

Back

Question 7 Composition is sometimes referred to as a(n) ________. Selected Answer:

Front

has-a relationship

Back

Question 14

Front

Which statement is true when a superclass has protected instance variables? Selected Answer: All of these.

Back

Question 10

Front

An advantage of inheritance is that ________. Selected Answer: objects of a subclass can be treated like objects of their superclass

Back

Ch. 9 Test Bank

Front

Back

Question 2

Front

Constructors ________. Selected Answer: Both initialize instance variables and when overloaded, are selected by number, types and order of types of parameters.

Back

Chapter 10 Test Bank

Front

Back

Question 8 When a subclass constructor calls its superclass constructor, what happens if the superclass's constructor does not assign a value to an instance variable? Selected Answer:

Front

The program compiles and runs because the instance variables are initialized to their default values.

Back

Question 1 Having a this reference allows ________. Selected Answer:

Front

All of these.

Back

Question 1 Which of the following is not a superclass/subclass relationship? Selected Answer:

Front

Sailboat/Tugboat Response Feedback: A Sailboat is not a superclass for Tugboats. Both sailboat and tugboats would be subclasses of Boat.

Back

Question 14

Front

A constructor cannot ________. Selected Answer: specify return types or return values

Back

Question 20 Which of the following keywords allows a subclass to access a superclass method even when the subclass has overridden the superclass method? Selected Answer:

Front

Super

Back

Question 4 Inheritance is also known as the ________. Selected Answer:

Front

is-a relationship

Back

Question 20 Instance variables declared final do not or cannot ________. Selected Answer:

Front

be modified after they are initialized

Back

Question 19 Which of the following statements is true? Selected Answer:

Front

Methods and instance variables can both be either public or private.

Back

Question 12 Class ________ represents an image that can be displayed on a JLabel. Selected Answer:

Front

ImageIcon

Back

Question 23 What happens when this is used in a constructor's body to call another constructor of the same class if that call is not the first statement in the constructor? Selected Answer:

Front

A compilation error occurs.

Back

Question 13 Which of the following statements is false? Selected Answer:

Front

If the class you're inheriting from declares instance variables as private, the inherited class can access those instance variables directly. Response Feedback: Actually, if the class you're inheriting from declares instance variables as protected, the inherited class can access those instance variables directly.

Back

Question 5

Front

The ________ of a class are also called the public services or the public interface that the class provides to its clients. Selected Answer: public methods

Back

Question 7

Front

Every class in Java, except ________, extends an existing class. Selected Answer: Object

Back

Question 22 Consider the classes below, declared in the same file:

Front

Back

Question 19 Which superclass members are inherited by all subclasses of that superclass? Selected Answer:

Front

protected instance variables and methods

Back

Question 4

Front

Which method returns an array of the enum's constants? Selected Answer: Values

Back

Section 2

(21 cards)

Question 20 Which interface is used to identify classes whose objects can be written to or read from some type of storage or transmitted across a network? Selected Answer:

Front

Serializable

Back

Question 11 If the superclass contains only abstract method declarations, the superclass is used for ________. Selected Answer:

Front

interface inheritance

Back

Question 6 Consider the abstract superclass below: Any concrete subclass that extends class Foo ________. Selected Answer:

Front

Both must implement a method called calculate and will not be able to access the instance variable a.

Back

Question 21 Which of the following statements is false? Selected Answer:

Front

With non-static interface methods, helper methods can now be declared directly in interfaces rather than in separate classes. Response Feedback: Actually, it's with static interface methods that helper methods can now be declared directly in interfaces rather than in separate classes.

Back

Question 10 Which of the following could be used to declare abstract method method1 in abstract class Class1 (method1 returns an int and takes no arguments)? Selected Answer:

Front

public abstract int method1();

Back

Question 5 Non-abstract classes are called ________. Selected Answer:

Front

concrete classes

Back

Question 19 A(n) ________ class cannot be instantiated. Selected Answer:

Front

abstract.

Back

Question 13 A class that implements an interface but does not declare all of the interface's methods must be declared ________. Selected Answer:

Front

abstract

Back

Question 18 In Java SE 7 and earlier, an interface may contain ________. Selected Answer:

Front

public static final data and public abstract methods

Back

Question 7 Which interface is specifically intended to be implemented by classes that can be used with the try-with-resources statement? Selected Answer:

Front

AutoCloseable

Back

Question 1 All of the following methods are implicitly final except ________. Selected Answer:

Front

a method in an abstract class

Back

Question 9 Classes and methods are declared final for all but the following reasons ________. Selected Answer:

Front

final methods are static

Back

Question 8 Which keyword is used to specify that a class will define the methods of an interface? Selected Answer:

Front

implements

Back

Question 14

Front

Which of the following does not complete the sentence correctly? An interface ________. Selected Answer: can be instantiated

Back

Question 17 Which of the following statements is false? Selected Answer:

Front

When you enhance an existing interface with default methods-any class that implemented the original interface will break. Response Feedback: Actually, when you enhance an existing interface with default methods-any class that implemented the original interface will not break-it'll simply receive the default method implementations.

Back

Question 4 Which of the following is not possible? Selected Answer:

Front

A class that inherits from two classes.

Back

Question 15

Front

It is a UML convention to denote the name of an abstract class in ________. Selected Answer: italics

Back

Question 2 Polymorphism allows for specifics to be dealt with during ________. Selected Answer:

Front

execution

Back

Question 3 When a superclass variable refers to a subclass object and a method is called on that object, the proper implementation is determined at execution time. What is the process of determining the method to call? Selected Answer:

Front

Late binding

Back

Question 16 For which of the following would polymorphism not provide a clean solution? Selected Answer:

Front

A program to compute a 5% savings account interest for a variety of clients. Response Feedback: Because there is only one kind of calculation, there is no need for polymorphism.

Back

Question 12 Every object in Java knows its own class and can access this information through method ________. Selected Answer:

Front

getClass

Back