Week 4 Flashcards
The portion of the program that can refer to the declared entity is referred to as the _____ of a declaration
Scope
The scope of a parameter is
The body of the method that the parameter is a part of
Scope: This type appears from the declaration to the end of the block
Local scope
Scope - The entire body of the class
Field scope
Are variable declarations limited only to certain blocks?
No, any block may conain variable declarations
If a local var/parameter has the same name as a field variable, what happens to the field variable? What is this called?
The field is hidden until the block finishes executing. This is called shadowing.
A class variable is like a field variable but it is
static (sometimes referred to as static fields)
Every instance of the class shares a _____ ________, which is in one fixed location in memory. This means any instances will access the same static ________
Class variable, variable
Do static fields belong to the class, or the instances of a class?
They belong to the class
T/F - Values of non-static fields are the same for every object
False
A field declared static and final is also called
A constant
T/F - Static methods can be accessed by all instances of a class
True
T/F - A static method/Class method belongs to the class, not the instance of a class
True
T/F - Methods that are defined in an instance are only accessible by that member of a class
True
3 things that happen when a variable or method is declared static
- Loaded into memory first
- Loaded into memory only once
- Loaded as part of the class, not an object