Java Interfaces And Abstract Classes MCQ - Quiz

  • A
    interface A { void print() { } }    
  • B
     abstract interface A { print(); } 
  • C
    abstract interface A { abstract void print(); { }}  
  • D
     interface A { void print(); } 
  • A class
  • B abstract class
  • C interface
  • D vaiable
  • A To prevent developers from further extending the class.
  • B When it doesn't make sense to have objects of that class.
  • C When default implementations of some methods are not desirable.
  • D To force developers to extend the class not to use its capabilities.
  • 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 The keywords public and abstract cannot be used together.
  • B The method numberOfStudent() in class School must have a body.
  • C You must add a return statement in method numberOfStudent().
  • D Class School must be defined abstract.