Java Interfaces And Abstract Classes MCQ - Quiz

  • A An abstract class can be extended.
  • B A subclass of a non-abstract superclass can be abstract.
  • C A subclass can override a concrete method in a superclass to declare it abstract.
  • D All of the above
  • A This code will not compile, because method doYourJob() in interface Guard must be defined abstract.
  • B This code will not compile, because class Dog must implement method doYourJob() from interface Guard.
  • C This code will not compile, because in the declaration of class Dog we must use the keyword extends instead of implements.
  • D This code will compile without any errors.
  • A The code will lead to a compilation error as declaration of the display method has been provided in two interface.
  • B The code will lead to a compilation error due to public modifier while declaring the display method.
  • C The code will compile and execute successfully showing the output Welcome to Examveda.
  • D The code will lead to a compilation error as the display method is not declared as abstract.
  • A class
  • B abstract class
  • C interface
  • D vaiable