- Executors
-
Learn
Learn Python Runnable examples, NumPy, pandas, and more Learn AI / Machine LearningNeural networks, ML and LLMs from scratch Learn C & C++ Pointers, memory, STL, and modern C++ Learn C#C# basics, OOP, LINQ, async, and .NET exercises Learn MatplotlibLine, bar, scatter and pie charts with live visualizers Learn RustOwnership, traits, error handling, and threads Learn GoSlices, interfaces, goroutines, and channels Python Algorithms Search, sorting, recursion, and visualizers O(n) C & C++ Algorithms Compare algorithms implemented in C and C++ Coding for Kids Learn to code by playing!
- QuizzesNew
- ChallengesNew
- For TeachersNew
- Updates
- Buy me a coffee
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.
Sample question
Question 1 of 10What 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,
defaultmethods and constants - Implementing interfaces with
publicmethods - 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.