Java OCA OCP Practice Question 2083

Question

Choose the correct option based on this code segment:.

class Rectangle { }
class ColoredRectangle extends Rectangle { }
class RoundedRectangle extends Rectangle { }
class ColoredRoundedRectangle extends ColoredRectangle, RoundedRectangle { }

Choose an appropriate option:.

  • a . Compiler error: '{' expected cannot extend two classes
  • B. Compiles fine, and when run, crashes with the exception MultipleClassInheritanceException
  • C. Compiler error: class definition cannot be empty
  • D. Compiles fine, and when run, crashes with the exception EmptyClassDefinitionError


A.

Note

Java does not support multiple class inheritance.

Since ColoredRectangle and RoundedRectangle are classes, it results in a compiler error when ColoredRoundedRectangle class attempts to extend these two classes.

It is acceptable for a class to be empty.




PreviousNext

Related