Static variables and constants Flashcards

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

Static variable definition:

A

an attribute that belongs to a class as a whole, not to individual objects (instances) of that class. Such an attribute is represented by a variable called static variable or class, which is declared with the keyword static

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

Static methods (methods that do not involve any particular instances of a class) cannot access or modify any instance variables and cannot refer to _____, because _____ is undefined when a static method is running

A

this

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

When a parameter is passed by value, the method works with a copy of the variable passed to it, so it has no way of changing the value of the original. What will be returned by:
int x = 3, y = 5
fun(x, y)
System.out.println(x + “ “ + y)

A

3, 5

Note that no matter what fun(x, y) actually does, it will not affect the values of x and y because it is only working with a copy

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