In a class definition in Java, if a modifier is not specified in the declaration
ID: 3859985 • Letter: I
Question
In a class definition in Java, if a modifier is not specified in the declaration of a data field's variable, which statement in the following is correct?
a) The variable is accessible to the class itself only
b) The variable is accessible to the class itself and all classes in the package.
c) The variable is private by default.
d) The variable is public by default.
a) The variable is accessible to the class itself only
b) The variable is accessible to the class itself and all classes in the package.
c) The variable is private by default.
d) The variable is public by default.
Explanation / Answer
In a class definition in Java, if a modifier is not specified in the declaration of a data field's variable
Answer:D
The variable is public by default.