Java OCA OCP Practice Question 7

Question

Which of the following restrictions apply to anonymous inner classes?

  • A. They must be defined inside a code block.
  • B. They may only read and write final variables of the enclosing class.
  • C. They may only call final methods of the enclosing class.
  • D. They may not call the enclosing class' synchronized methods.


A.

Note

An anonymous inner class must appear inside a block of code.

We can call an anonymous inner class by accessing the enclosing class's non-final data or methods or the enclosing class's synchronized methods.




PreviousNext

Related