Consider the declarations inside main. Which statement is correct immediately after these declarations?
public static void main(String[] args) {
int attempts;
double temperature;
boolean connected;
String teamName;
}
main.teamName is local because String is a class.0.main.
Explanation
A declaration introduces a variable by writing its type followed by its name. Each of the four lines does exactly that, and each one is written inside the braces of main.
- B is not correct: a variable is local because of where it is declared, not because of which type it has.
Stringis a reference type, butteamNameis declared insidemainjust like the other three. - C is not correct: these declarations do not assign values to the local variables, so none of them is given the value
0. - D is not correct: Java does not allow a local variable's value to be read until a value has been assigned to it, so none of the four contains a usable value yet.