Java OCA OCP Practice Question 1073

Question

Which of the following are true about this variable declaration?

private static int i = 3;  
  • A. The value of i may not be changed after it is assigned a value.
  • B. i may only be updated by a static method.
  • C. The value of i is shared among all instances of the class in which it is declared.
  • D. i may only be accessed within the class in which it is declared.


C and D.

Note

Because i is static it is shared among all instances of its class.

Because i is private it may only be accessed within the class in which it is declared.




PreviousNext

Related