Java Interfaces And Abstract Classes MCQ - Quiz

  • Aclass A { abstract void unfinished() { } }
  • Bclass A { abstract void unfinished(); }
  • Cabstract class A { abstract void unfinished(); }
  • Dpublic class abstract A { abstract void unfinished(); }
  • AAn abstract class can be extended.
  • BA subclass of a non-abstract superclass can be abstract.
  • CA subclass can override a concrete method in a superclass to declare it abstract.
  • DAll of the above
  • A
    interface A { void print() { } }    
  • B
     abstract interface A { print(); } 
  • C
    abstract interface A { abstract void print(); { }}  
  • D
     interface A { void print(); } 
  • AThis code will not compile, because method doYourJob() in interface Guard must be defined abstract.
  • BThis code will not compile, because class Dog must implement method doYourJob() from interface Guard.
  • CThis 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.
  • AThe code will lead to a compilation error as declaration of the display method has been provided in two interface.
  • BThe 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.
  • DThe code will lead to a compilation error as the display method is not declared as abstract.