Java SE 11: Objects & Classes Flashcards

1
Q
A

Behavior

C D

Property

A B E

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
A

A Noun

B Adjective

C Verb

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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

A

√ Object reference

Reserved world

Class

Primitive type

√ Reference variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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
A

How objects are accessed using object references

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

A

You need a variable reference of the correct type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A

G

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A

Object stored on the heap

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What keyword is used to invoke a constructor?

new

object

class

public

construct

A

new

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What return type is specified by a constructor method?

New

Class

Public

No type is specific

A

No type is specific

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a value passed into a method called?

Parameter

Class

Argument

Object reference

A

Argument

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Given a function that specifies a return type of void, what will it return?

A class

A void reference

Nothing

An object reference

A

Nothing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Select the elements that make up a method signature.

▢ Number parameters

▢ Modifier

▢ Parameter types

▢ Method name

▢ Return type

▢ Order of parameters

A

√ Number parameters

▢ Modifier

√ Parameter types

√ Method name

▢ Return type

√ Order of parameters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

A

The Shirt class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Devide section by Class name, Fields and Methods.

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What’s the difference between declaring an object and instatiating an object

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

what is the . operator for?

A

The period . operator is used to access the fields and methods of an object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

In java you access objects using ________

A

references

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Objects are created or ________ by their class type.

A

instantiated

20
Q

Any object consist of properties and operations, which we call _____ and ______ in Java

A

Any object consist of properties and operations, which we call fields and methods in Java

21
Q

References point to a particular object in _____

22
Q

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?

A

Two objects in memory

23
Q

A primitive type int is stored as an object.

True or False

24
Q

A primitive type int is stored as a _______.

25
Variable types and references are store in the \_\_\_\_\_
stack
26
Object types are store in the \_\_\_\_\_
Heap
27
The stack holds local variables, either ______ or _______ \_\_\_\_
The stack holds local variables, either **primitives** or **reference types**
28
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.
29
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**.
30
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 };
31
## Footnote 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**
32
The public keyword is a \_\_\_\_\_
The **public** keyword is a \_\_\_\_\_
33
## Footnote **\_\_\_\_** is a keyword that indicates that the method does not return a value
## Footnote **void** is a keyword that indicates that the method does not return a value
34
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.
35
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
36
A constructor method is called by using the **\_\_\_** keyword.
**new** Shirt myShirt = **new** Shirt ( )
37
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)
38
The method signature does not include the _____ \_\_\_\_
return type
39
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.
40
A variable is usually called a _____ when it's in a class
**field**
41
Instance variables or fields are stored in the long term memory \_\_\_\_
Instance variables or fields are stored in the long term memory **heap**
42
An instance variable is accessible from any code within this \_\_\_\_
**class**
43
Local variables are stored in the **\_\_\_\_**
**stack**
44
A local variable is ______ from ______ when the method ends
A local variable is **deleted** from **memory** when the method ends
45
A **\_\_\_\_ \_\_\_\_\_** in Java is a variable that's declared within the body of a method.
**local variable**
46
**\_\_\_\_\_\_ \_\_\_\_\_\_\_\_\_** 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)
47
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
## Footnote **class**