Java Interfaces And Abstract Classes MCQ

Programming Language > Java Programming Language

Assess your knowledge of Java interfaces and abstract classes with these multiple choice questions. Learn about the difference between the two concepts and how to use them to create flexible and scalable Java programs. Take the quiz now!

➲ Java Interfaces And Abstract Classes MCQ - Quiz

  • A class A { abstract void unfinished() { } }
  • B class A { abstract void unfinished(); }
  • C abstract class A { abstract void unfinished(); }
  • D public class abstract A { abstract void unfinished(); }
  • A public abstract method();
  • B public abstract void method();
  • C public void method() {}
  • D public void abstract Method();
  • 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 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.
  • A
    interface A { void print() { } }    
  • B
     abstract interface A { print(); } 
  • C
    abstract interface A { abstract void print(); { }}  
  • D
     interface A { void print(); } 
  • 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 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 class
  • B abstract class
  • C interface
  • D vaiable
  • A test-name
  • B Compilation fails due to an error on lines 1
  • C Compilation fails due to an error on lines 2
  • D Compilation succeed but Runtime Exception
  • A Program will compile and execute successfully and prints
  • B Compilation error as class can not be declared as abstract.
  • C Program compiles but leads to runtime exception.
  • D Compilation error occurs as the abstract class TestAbstract contains a non-abstract method.
  • 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.