|
1.1
|
Which statement is true about a method?
Select the one correct answer.
-
A method is an implementation of an abstraction.
-
A method is an attribute defining the property of a particular abstraction.
-
A method is a category of objects.
-
A method is an operation defining the behavior for a particular abstraction.
-
A method is a blueprint for making operations.
|
|
1.2
|
Which statement is true about an object?
Select the one correct answer.
-
An object is what classes are
instantiated
from.
-
An object is an instance of a class.
-
An object is a blueprint for creating concrete realization of abstractions.
-
An object is a reference to an attribute.
-
An object is a variable.
|
|
1.3
|
Which line contains a constructor in this class definition?
public class Counter { // (1)
int current, step;
public Counter(int startValue, int stepValue) { // (2)
set(startValue);
setStepValue(stepValue);
}
public int get() { return current; } // (3)
public void set(int value) { current = value; } // (4)
public void setStepValue(int stepValue) { step = stepValue; } // (5)
}
Select the one correct answer.
-
Code
marked
with (1) is a constructor.
-
Code marked with (2) is a constructor.
-
Code marked with (3) is a constructor.
-
Code marked with (4) is a constructor.
-
Code marked with (5) is a constructor.
|
|
1.4
|
Given that
Thing
is a class, how many objects and how many reference
variables
are created by the following code?
Thing item, stuff;
item = new Thing();
Thing entity = new Thing();
Select the two correct answers.
-
One object is created.
-
Two objects are created.
-
Three objects are created.
-
One reference variable is created.
-
Two reference variables are created.
-
Three reference variables are created.
|
|
1.5
|
Which statement is true about an instance method?
Select the one correct answer.
-
An instance member is also called a static member.
-
An instance member is always a field.
-
An instance member is never a method.
-
An instance member belongs to an instance, not to the class as a whole.
-
An instance member always represents an operation.
|
|
1.6
|
How do objects pass messages in Java?
Select the one correct answer.
-
They pass messages by modifying each other's fields.
-
They pass messages by modifying the static variables of each other's classes.
-
They pass messages by calling each other's instance
methods
.
-
They pass messages by calling static methods of each other's classes.
|
|
1.7
|
Given the following code, which statements are true?
class A {
int value1;
}
class B extends A {
int value2;
}
Select the two correct answers.
-
Class
A
extends class
B
.
-
Class
B
is the superclass of class
A
.
-
Class
A
inherits from class
B
.
-
Class
B
is a subclass of class
A
.
-
Objects of class
A
have a field named
value2
.
-
Objects of class
B
have a field named
value1
.
|