Section 1

Preview this deck

What statement about the comparing objects is correct?

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 (11)

Section 1

(11 cards)

What statement about the comparing objects is correct?

Front

The equals method is used to compare whether two objects have the same contents

Back

What reserved word in a method definition ensures that sublcassess cannot override the method?

Front

Method: Final

Back

What reserved word must be used to call a method of a superclass?

Front

Super

Back

Consider the follwing code snippet: Vechile aVehicle = new Auto(); aVehicle.moveForward(200); If the Auto class inherits from the Vehicle class, and both classes have an implementation of the moveForward method with the same set of parameters and the same return type, what statement is correct?

Front

The moveForward method of the Auto class will be executed

Back

All hamsters are rodents and all rodents are mammals. What hierarchy best captures this information?

Front

The mammal is a superclass of Rodent and Rodent is a superclass of Hamster

Back

Consider the code below: public class Parent { public int getValue(){ return 24; } public void display(){ System.out.print(getValue() + " " ); } } public class Child extends Parent { public int getValue(){ return -7; } } What is the output of the following lines? Parent kid = new Child(); Parent adult = new Parent(); kid.display(); adult.display();

Front

-7 24

Back

Consider the following code snippet: public class Auto extends Vehicle { public Auto (int numberAxles) { super(numberAxles); } } What does this code do?

Front

It invokes the constructor of the Vehicle class from within the constructor of the Auto class.

Back

When declared as protected, what is true about the access to data in an object?

Front

The data is accessible only by that class's methods, by all of its subclasses, and by methods in classes within the same package

Back

To ensure that an instance variable can only be accessed by the class that declared it, how should the variable be declared?

Front

Private

Back

What reserved word in a class definition ensures that subclasses cannot be created from the class?

Front

Class: Final

Back

When the reserved word super is followed by parenthesis (super()), what does this indicate?

Front

A call to a superclass constructor

Back