Week 4 Flashcards

1
Q

an object created from a class has …

A

a state and behaviors

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

all classes that represent objects should …

A

declare a toString method

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

a constructor is called by …

A

the new operator to create an object and set its initial state. It looks similar to a method but has the same name as the class and has no return type.

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

a constructor may or may not have parameters. A class may have multiple constructors.

A

a constructor may or may not have parameters. A class may have multiple constructors.

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

the scope of a variable defines …

A

where it can be referenced; determined where the variable is declared (its enclosing block)

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

instance variables

A

(fields declared in the class black) can be referenced by all methods in that class.

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

local variables

A

variables (declared inside of a method) can only be referenced within that method.

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

UML

A

Unified Modeling Language - shows the relationship among classes in the program

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

-three kinds of access modifiers:

A
public(anywhere), protected, and private(within the class)
-no access modifiers access is default and can be referenced within the class and by classes in the same package
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Access (Visibility) Modifiers

A

Public Private
Instance Variables Violate encapsulation Enforce encapsulation
Methods Provides services to clients Support other methods in the class

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

An accessor method returns …

A

the current value of a variable (getter) getX()

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

A mutator method changes …

A

the value of a variable (setter) setX()

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

The return type of a method indicates…

A

the type of value that the method sends back to the calling location.

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

magic numbers

A

do not use magic numbers in constant fields

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

unlike variables, constants can be …

A

public without violating encapsulation

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