Java Abstract Classes & Interfaces Quiz

This Java quiz checks how abstract classes and interfaces define contracts for other classes. You will predict output with abstract methods, default methods and lambdas, and spot the rules the compiler enforces when you implement them.

Medium 10 questions ~6 minutes Pass at 80% Java 17

Choose a mode

Playing as a guest: sign in to keep your XP and streak.

Sample question

Question 1 of 10

What happens when you compile and run this?

public class Main {
    static abstract class Shape {
        abstract double area();
    }

    public static void main(String[] args) {
        Shape s = new Shape();
        System.out.println(s.area());
    }
}
Show the answer

A. Compile error An abstract class cannot be instantiated with new, because some of its methods have no body. You create a concrete subclass, or an anonymous class, instead.

What this quiz covers

  • Abstract classes and abstract methods
  • Interfaces, default methods and constants
  • Implementing interfaces with public methods
  • Functional interfaces and lambdas
  • Choosing between an abstract class and an interface

Questions people ask

Do I need an account?

No. Anyone can play. Sign in to keep your XP, streak, badges and history.

Can I retake it?

Yes. Your best score is kept, and the questions and answers are shuffled each time.