Java SE 11: Objects & Classes Flashcards
Behavior
C D
Property
A B E
A Noun
B Adjective
C Verb
Given the following code, select the answers which best describe the type of variable alice
.
Customer alice = new Customer( );
▢ Object reference
▢ Reserved world
▢ Class
▢ Primitive type
▢ Reference variable
√ Object reference
Reserved world
Class
Primitive type
√ Reference variable
Given the analogy of a remote
to control a camera, what does this describe in Java?
- How objects are accessed using object references
- How multiple objects can represent Java objects
- How objects consist of properties and operations
- How objects are created or instantiated by their class type
How objects are accessed using object references
Select the necessary condition for a variable to reference an object.
You need a copy of the instantiated class
You need to use the remote keyword
You need a variable reference of the correct type
You need a universal variable
You need a variable reference of the correct type
What should be the output of the following code snippet?
Shirt myShirt = new Shirt(); Shirt yourShirt = new Shirt();
myShirt = yourShirt; myShirt.colorCode = 'R'; yourShirt.colorCode = 'G';
System.out.println(myShirt.colorCode);
myShirt
G
R
yourShirt
G
Select the answer which describes how Java arrays are stored in memory.
Memory addresses on the heap
Primitive elements on the stack
Object stored on the heap
Object references on the stack
Object stored on the heap
What keyword is used to invoke a constructor?
new
object
class
public
construct
new
What return type is specified by a constructor method?
New
Class
Public
No type is specific
No type is specific
What is a value passed into a method called?
Parameter
Class
Argument
Object reference
Argument
Given a function that specifies a return type of void, what will it return?
A class
A void reference
Nothing
An object reference
Nothing
Select the elements that make up a method signature.
▢ Number parameters
▢ Modifier
▢ Parameter types
▢ Method name
▢ Return type
▢ Order of parameters
√ Number parameters
▢ Modifier
√ Parameter types
√ Method name
▢ Return type
√ Order of parameters
Given the following code, what is the scope of the price
field?
public class Shirt {
public String description;
public char colorCode;
public double price;
public void setPrice(double thePrice) {
price = thePrice;
}
public double getPrice() {
return price;
}
The global application
The Shirt class
The setPrice method
The getPrice method
The Shirt class
Devide section by Class name, Fields and Methods.
What’s the difference between declaring an object and instatiating an object
No value is assigned when an object is just declared.
Initialization is the assignment of a value to a variable at the time of declaration.
what is the . operator for?
The period . operator is used to access the fields and methods of an object.
In java you access objects using ________
references