Chapter 6 Flashcards

You may prefer our related Brainscape-certified 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
Q

If the method returns no value, the return type should be ___.

A

if the method returns no value, the return type should be void

26
Q

What does a return stmt in a void method do?

A

Simply ends the method

27
Q

True or False: a method can have multiple return statements:

A

True! a method can have multiple return statements

28
Q

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.

A

True. if a method has a return type, implementation must have at least one return statement that returns a value of that type.

29
Q

What are formal parameters?

A

formal parameters are parameters listed in a method’s definition

30
Q

What are actual parameters?

A

values passed to a method when it is invoked

31
Q

what are helper methods?

A

used by another method to perform part of larger task.

32
Q

are helper methods usually public or private?

A

they are usually private: only methods already defined within the class need to use them

33
Q

Describe the characteristics of global variables:

A
  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
Q

Describe the characteristics of local variables

A
  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
Q

what is the scope of a variable?

A

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
Q

where is the scope only visible?

A

it is visible only within code enclosed by braces

37
Q

what is the scope of a local variable?

A

it is usable in the body of the method that declares it

38
Q

what is the lifetime of a variable?

A

the period when a variable can be used.

39
Q

what is the lifetime of a private instance variable?

A

they exist as long as the object exists