Chapter 6 Flashcards

1
Q

What is a class?

A

It is the template that describes characteristics of similar objects; blueprint to create objects of that class

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

What is an object?

A

it is an instance of its’ class

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

What kind of entity is an object?

A

It is a run time entity that contains date and responds to messages.

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

what is encapsulation?

A

combining data and behavior into a single software package

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

name the three characteristics of objects

A

state, behavior, identity

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

What is the state of an object?

A

instance variables

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

What goes into the behavior of an object?

A

Methods! which define an object’s behavior in response to messages. there are two types: mutators and accessors

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

What’s the difference between mutators and accessors?

A

mutators change an object’s state. accessors access the object’s state

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

what does a computer’s memory hold during execution?

A

variables that refer to objects, class templates, and objects

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

Objects appear and occupy memory when instantiated and disappear when no longer need, through a process called ______.

A

Garbage collection, which is the JVM’s automated method for removing unused objects.

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

What else does the garbage collection do?

A

it also tracks whether objects are referenced by any variables.

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

describe the client and server relationship

A

Client is the message sender, server is the message receiver. Client only needs to know the interface, server implements and supports the interface

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

What is an interface?

A

list of methods

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

What is information hiding?

A

server’s data requirements and methods implementation hidden from THE CLIENT

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

Name the two types of visibility modifiers

A

private and public.

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

Define the private visibility modifier

A

only accessible in the enclosing class

17
Q

Define the public visibility modifier

A

class is accessible to anyone

18
Q

generally, what type of visibility modifiers should instance variables be?

A

Private! instance variables should generally be private.

19
Q

What do constructors do?

A
  • initialize a newly instantiated object’s instance variables.
  • activated only by the keyword new
20
Q

What happens with default constructors and their parameters?

A

Empty parameter lists.

21
Q

Name the two fundamental data type categories

A

Primitive (int, double, boolean, char) and reference (all classes, the objects they create.)

22
Q

what is the null pointer exception?

A

to cause a variable to no longer point at any object; set it equal to null

23
Q

should we avoid null pointer exceptions?

A

yes!!! we really should avoid null pointer exceptions.

24
Q

true or false: constructors are used when creating an object AND updating or resetting values

A

FALSE! constructors are only used when creating an object, NOT updating or resetting values

25
If the method returns no value, the return type should be ___.
if the method returns no value, the return type should be void
26
What does a return stmt in a void method do?
Simply ends the method
27
True or False: a method can have multiple return statements:
True! a method can have multiple return statements
28
True or false: if a method has a return type, implementation must have at least one return statement that returns a value of that type.
True. if a method has a return type, implementation must have at least one return statement that returns a value of that type.
29
What are formal parameters?
formal parameters are parameters listed in a method's definition
30
What are actual parameters?
values passed to a method when it is invoked
31
what are helper methods?
used by another method to perform part of larger task.
32
are helper methods usually public or private?
they are usually private: only methods already defined within the class need to use them
33
Describe the characteristics of global variables:
1. they are declared inside a class but outside any method; 2. accessible to any method in the class 3. held in memory as long as the object is held in memory
34
Describe the characteristics of local variables
1. they are only declared inside a method 2. accessible only within that method 3. once it's already done its' job, it disappears. gets replaced
35
what is the scope of a variable?
the region where a variable can validly appear in lines of code. variables declared within any compound statement enclosed in braces have block scope.
36
where is the scope only visible?
it is visible only within code enclosed by braces
37
what is the scope of a local variable?
it is usable in the body of the method that declares it
38
what is the lifetime of a variable?
the period when a variable can be used.
39
what is the lifetime of a private instance variable?
they exist as long as the object exists