Java OCA OCP Practice Question 83

Question

Which of the following variables are always in scope for the entire program?

  • A. Package variables
  • B. Class variables
  • C. Instance variables
  • D. Local variables


B.

Note

There is no such thing as package variables, so Option A is incorrect.

Option C is incorrect as the variable is only in scope within a specific instance of the class.

Option D is also incorrect as the variable is only in scope for a single method that it is defined in.

Option B is the only correct answer as class variables are in scope within the program.




PreviousNext

Related