Week 4 Flashcards

1
Q

The portion of the program that can refer to the declared entity is referred to as the _____ of a declaration

A

Scope

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

The scope of a parameter is

A

The body of the method that the parameter is a part of

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

Scope: This type appears from the declaration to the end of the block

A

Local scope

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

Scope - The entire body of the class

A

Field scope

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

Are variable declarations limited only to certain blocks?

A

No, any block may conain variable declarations

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

If a local var/parameter has the same name as a field variable, what happens to the field variable? What is this called?

A

The field is hidden until the block finishes executing. This is called shadowing.

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

A class variable is like a field variable but it is

A

static (sometimes referred to as static fields)

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

Every instance of the class shares a _____ ________, which is in one fixed location in memory. This means any instances will access the same static ________

A

Class variable, variable

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

Do static fields belong to the class, or the instances of a class?

A

They belong to the class

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

T/F - Values of non-static fields are the same for every object

A

False

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

A field declared static and final is also called

A

A constant

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

T/F - Static methods can be accessed by all instances of a class

A

True

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

T/F - A static method/Class method belongs to the class, not the instance of a class

A

True

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

T/F - Methods that are defined in an instance are only accessible by that member of a class

A

True

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

3 things that happen when a variable or method is declared static

A
  1. Loaded into memory first
  2. Loaded into memory only once
  3. Loaded as part of the class, not an object
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

T/F - Any references made to static members will create a new member

A

False

17
Q

T/F - the Math class is a static method

A

True

18
Q

T/F - Method arguments for a static method may be variables and expressions, but not constants

A

False. They may be Vars, expressions, or constants

19
Q

T/F - Math.ceil, math.floor, and math.exp are examples of Math methods

A

True

20
Q

T/F - Math.power, math.sub, math.sin are examples of math methods

A

False - math.sub is not

21
Q

T/F math.log, math.max, math.sqrt are examples of math methods

A

True

22
Q

Each object of a class maintains its ___ ____ of every instance variable of the class

A

own copy

23
Q

T/F - Instance variables are referred to as fields, static variables are not

A

False, both are fields

24
Q

The PI and E constants in the Math class are declared with the modifiers public, _____, and ______

A

final and static