Ch. 5- Data Types, Variables and Arithmetic #1-6
Which of the following statements prints a backslash?
B
Which variables in a class have global scope access?
B
The scope of a variable is determined when the program is ___________? (compiled, executed)
Compiled
If a local variable in a method and a field have the same name, the compiler reports a syntax error T or F?
False; Java allowed the usage of local variables in both methods and fields, but this creates bugs that may be hard to find.
The scope of the variable is the largest range of its values T or F?
False; The scope of a variable is defined only within a certain space.
k is always a stylistically bad name for a variable because it is too short T or F?
False; single letters are predominantly used to represent variables.
Which of the following lines are synthetically valid declarations of fields? Of local variables?
Fields: a,b,c Local Variables: d,e,f
Name three good reasons for using symbolic constants as opposed to literal constants.
Make code more readable/ more self-explanatory, easier to change into a variable, and simplifies program maintenance
Each Variable must be explained on a separate line T or F?
True; A variable can only be declared once within the space where the where the variable is "visible"
Local variables in different methods of the same class are allowed to have the same name T or F?
True; As long as they aren't within the same scope.