Java OCA OCP Practice Question 1298

Question

Fill in the blanks:

A class that defines an instance variable with the same name as a variable in the parent class is referred to as ___ a variable, while a class that defines a static method with the same signature as a static method in a parent class is referred to as ___ a method.

  • A. hiding, overriding
  • B. overriding, hiding
  • C. hiding, hiding
  • D. replacing, overriding


C.

Note

Both of these descriptions refer to variable and static method hiding, respectively, making Option C correct.

Only instance methods can be overridden, making Options A and B incorrect.

Option D is also incorrect because replacing is not a real term in this context.




PreviousNext

Related