Quiz di Java: Abstract Classes & Interfaces

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.

Medio 10 domande ~6 minuti Superato con il 80% Java 17

Scegli una modalità

Stai giocando come ospite: accedi per salvare XP e serie.

Domanda di esempio

Domanda 1 di 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());
    }
}
Mostra la risposta

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.

Cosa copre questo quiz

  • 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

Domande frequenti

Serve un account?

No. Chiunque può giocare. Accedi per salvare XP, serie, badge e cronologia.

Posso rifarlo?

Sì. Il tuo miglior punteggio resta salvato, e domande e risposte vengono mescolate ogni volta.