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
Objects are created or ________ by their class type.
instantiated
Any object consist of properties and operations, which we call _____ and ______ in Java
Any object consist of properties and operations, which we call fields and methods in Java
References point to a particular object in _____
memory
In this snippet of code we have three variables:
int counter = 10
Shirt myShirt = new Shirt
Shirt yourShirt = new Shirt.
How many objects end up in memory?
Two objects in memory
A primitive type int is stored as an object.
True or False
False
A primitive type int is stored as a _______.
variable
Variable types and references are store in the _____
stack
Object types are store in the _____
Heap
The stack holds local variables, either ______ or _______ ____
The stack holds local variables, either primitives or reference types
What happens if you assign an existing reference to another reference?
The existing reference will drop it’s current object and re-assigned to the same object of the new reference.

An array is actually an _____ type and is handled implicitly through an internal class in Java called _____.
An array is actually an object type and is handled implicitly through an internal class in Java called Array.
Like other object types with string being an exception, an array must be instantiated using the ___ keyword
Like other object types with string being an exception, an array must be instantiated using the new keyword
int[] ages = new int [4];
exception: int[] ages = { 8, 7, 5, 3 };
Arrays are _____ in memory that are referred to by an object _____ _____
Arrays are objects in memory that are referred to by an object reference variable

The public keyword is a _____
The public keyword is a _____
____ is a keyword that indicates that the method does not return a value
void is a keyword that indicates that the method does not return a value
The _____/_____ method is the main method or a method that calls another method to do work.
The caller /calling method is the main method or a method that calls another method to do work.
A __________ ______ is a special method that is invoked when you create an object instance
A Contrustor Method is a special method that is invoked when you create an object instance
A constructor method is called by using the ___ keyword.
new
Shirt myShirt = new Shirt ( )
The _____ _______ is the unique combination of a method’s name, the number, types, and order of its parameters.
The Method Signature is the unique combination of a method’s name, the number, types, and order of its parameters.
public double add (double x, double y)
public int add (int x, int y)
The method signature does not include the _____ ____
return type
So the _____ of a variable determines where you can access the variable and for how long you can count on its value to persist.
So the scope of a variable determines where you can access the variable and for how long you can count on its value to persist.
A variable is usually called a _____ when it’s in a class
field
Instance variables or fields are stored in the long term memory ____
Instance variables or fields are stored in the long term memory heap
An instance variable is accessible from any code within this ____
class
Local variables are stored in the ____
stack
A local variable is ______ from ______ when the method ends
A local variable is deleted from memory when the method ends
A ____ _____ in Java is a variable that’s declared within the body of a method.
local variable
______ _________ is a feature that allows a class to have more than one method having the same name, if their ______ lists are different
Method Overloading is a feature that allows a class to have more than one method having the same name, if their argument lists are different
add(int, int)
add(int, int, int)
add(int, float)
add(float, int)
A ____, in the context of Java, are templates that are used to create objects, and to define object data types and methods. Core properties include the data types and methods that may be used by the object
class