Final Gaddis Chap 3 part 2 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

UML diagrams are

A

language independent

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

UML diagrams use

A

an independent notation to show return types, access modifiers, etc

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

variable types are placed

A

after the variable name, separated by a colon
ex:
-width: double

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

Access modifiers are denoted as

A

+ for public
- for private
# for protected

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

method return types are placed

A

after the method declaration name, separated by a colon

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

method parameters are placed

A

inside parenthesis after the setMethod

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

UML order from top to bottom

A

ClassName, Attributes (Variables to be initiated), Methods (Constructor, getters, setters, calculations)

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

Can methods have multiple parameters?

A

Yes.

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

Parameters in methods are treated as

A

local variables within the method

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

In Java, all arguments to a method are passed…

A

“by value”

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

if the argument is a reference to an object

A

it is the reference that is passed to the method

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

if the argument is a primitive,

A

a copy of the value is passed to the method

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

instance fields and methods

A

fields and methods that are declared as previously shown

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

objects created from a class each have their own copy of

A

instance fields

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

instance methods are methods that are not declared with a special keyword…

A

static

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

instance fields and instance methods require

A

an object to be created in order to be used

17
Q

constructors have a few special properties that set them apart from normal methods

A

1) have same name as the class
2) have to return type (not even void)
3) they cannot return any values
4) are public

18
Q

write a constructor for the Payroll class with argument String n and int i

A
public Payroll (String n, int i)
{
name=n;
idNumber=i;
}
19
Q

In a UML chart, you can tell what the constructor is because

A

it will not have a return type and it will share a name with the class

20
Q

Scope of a variable inside of a method

A

visible only within that method, called a local variable

21
Q

scope of a variable inside a method parameter

A

called a parameter variable (same as local variable) and visible only within that method

22
Q

Scope of a variable inside the class but not in a method

A

visible to all methods of the class, called an instance field

23
Q

within a method, variable names must be

A

unique

24
Q

shadowing

A

a method having a local variable with the same name as an instance field (hides value of instance field) this is discouraged