CPS181

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

True, t

The key word this is the name of a reference variable that an object can use to refer to itself. (T or F).

"has a"

The whole-part relationship created by object aggregation is more often called a(n) ________ relationship.

The method header must begin with the key word default

What is required for an interface method that has a body?

final

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

a reference to an object of that class

When a method's return type is a class, what is actually returned to the calling program?

the method has access to the object that the variable references

When a reference variable is passed as an argument to a method ________.

True, t

When a subclass extends a superclass, the public members of the superclass become public members of the subclass.

Lambda

___________ is a special type of expression used to create an object that implements a functional interface.

after the access specifier and before the field's data type

A static field is created by placing the key word static ___________.

abstract

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

ClassC

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

ClassA

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

True, t

Instance methods do not have the key word static in their headers. (T or F).

public class ClassA implements Interface1, Interface2

Give an example specifying two interfaces in ClassA.

a chain of inheritance

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

#

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

Class Hierarchy

What shows the inheritance relationships among classes in a manner similar to that of a family tree?

"is a "

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

overloaded

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

methods in the same package or subclass, even when the subclass is in another package

Protected members may be accessed by _________.

True, t

A single copy of a class's static field is shared by all instances of the class. (T or F).

True, t

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

default, no-arg constructor

If a subclass constructor does not explicitly call a superclass constructor, what will java automatically call?

write a method for the class that will make a field by field copy of object1 data members into object2 data members

If object1 and object2 are objects of the same class, to make object2 a copy of object1 ________.

Extends

What is the key word that indicates that a class inherits from another class?

True, t

When an object is passed as an argument, it is actually a reference to the object that is passed. (T or F).

private members

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

intstanceOf

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

static

Static methods can only operate on ________ fields.

protected

A _____________ member's access is somewhere between public and private.

abstract

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

True, t

A class's static methods do not operate on the fields that belong to any instance of the class. (T or F).

True, t

A compiler error will result if an anonymous inner class tries to use a variable that is not final, or not effectively final. (T or F).

enum

A declaration for an enumerated type begins with the __________ key word.

True, t

A functional interface is simply an interface that has one abstract method.

Class, Package, A Subclass

A protected member may be directly accessed by methods of/in [the same] ___________.

are treated as final and static

All fields declared in an interface ___________.

False, f

All methods in an abstract class must also be declared abstract. (T or F).

public

All methods specified by an interface are ____________.

True, t

An abstract class is not instantiated itself but serves as a superclass for other classes.

True, t

Because every class directly or indirectly inherits from the object class, every class inherits the object class's members.

True, t

Because the subclass is more specialized than the superclass, it is sometimes necessary for the subclass to replace inadequate superclass methods with more suitable ones.

True, t

Both instance fields and instance methods are associated with a specific instance of a class, and they cannot be used until an instance of the class is created. (T or F).

int[] array1 = new int[10];

Declare an array named "array1" and allot it 10 spaces.

True, t

Every class has a toString method and an equals method inherited from the object class.

int x = x * factor;

Give an example of a lambda expression.

only public and protected members of the superclass

A subclass can directly access ___________.

public methods, protected methods

A subclass can directly access only ____________.

super.methodName();

A subclass may call an overridden superclass method by _________.

The account object's toString method will be implicitly called.

Assume the class BankAccount has been created and the following statement correctly creates an instance of the class. BankAccount account = new BankAccount(5000.00); What is true about the following statement?

the program will terminate

If you attempt to perform an operation with a null reference variable ____________.

package

If you don't provide an access specifier for a class member, the class member is given __________ access by default.

True, t

If you write a toString method for a class, Java will automatically call the method any time you concatenate an object of the class with a string. (T or F).

0

Java automatically stores a ________ value in all uninitialized static member variables.

whole-part relationship

The "has a" relationship is sometimes called a(n) ________ because one object is part of a greater whole.

write an equals method that will make a field by field compare of the two objects

To compare two objects in a class, ________.

public class ClassA extends ClassB

Write a statement that declares ClassA as a subclass of ClassB.

True, t

You can write a super statement that calls a superclass constructor but only in the subclass's constructor. (T or F).

Encapsulation

____________ refers to combining data and code into a single object.

@Override

____________ tells the java compiler that a method is meant to override a method in a superclass.

True, t

An instance of a class does not have to exist in order for values to be stored in a class's static fields. (T or F).

only one copy of the field in memory

When a field is declared static there will be ________.

True, t

When a subclass overrides a superclass method, only the subclasses version can be called with a subclass object. (T or F).

all of the characteristics of the general object plus additional characteristics

When an "is a " relationship exists between objects, the specialized object has ___________.

the object's memory address

When an object is passed as an argument to a method, what is passed into the method's parameter variable?

False, f

If two methods in the same class have the same name but different signatures, the second overrides the first.

the superclass constructor always executes before the subclass constructor

In an inheritance relationship ___________.

general classes are at the top, and specific classes are on the bottom

In class hierarchy ___________.

ClassB

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

False, f

Inheritance involves a subclass, which is the more general class, and a superclass, which is the specialized class. (T or F).

method overriding

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

super

The ___________ key word is used to call a superclass constructor explicitly.

True, t

If you write a toString method to display the contents of an object, object1, for a class, Class1, then the following two statements are equivalent: System.out.println(object1); System.out.println(object1.toString()); (T or F).

polymorphic

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.

a UML diagram

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

is an operation that copies an aggregate object and all the objects that it references

In an aggregation relationship, a deep copy of an object ___________.

both methods may be called with a subclass object

When a subclass overloads a superclass method ___________.

True, t

It is not possible for a superclass to call a subclass's method. (T or F)

True, t

When an object reference is passed to a method, the method may change the values in the object. (T or F).


संबंधित स्टडी सेट्स

Good? ATI Mood Disorder and Suicide Questions

View Set

PATHO: Ch. 20 Disorders of Brain Function

View Set

Data Types and Variable Operators - Lesson 2 Mod 12

View Set