Last Updated: January 3, 2026
31 quizzes
Ensure this class cannot be instantiated directly because it serves only as a base for payment types
public class PaymentProcessor {Click an option to fill the blank:
Allow this class to promise that it supports basic logging behavior defined elsewhere
public class ServiceLogger Loggable {Click an option to fill the blank:
Declare a method in an interface that must be implemented by all task types
void executeTaskClick an option to fill the blank:
Which statement about abstract classes is true?
In an abstract class, what must a non-abstract (concrete) subclass do?
Which is a valid reason to use an interface instead of an abstract class?
Which keyword is used to declare an abstract method in an abstract class?
What is true about default methods in interfaces?
How are static methods in interfaces accessed?
Which statement about private methods in interfaces is correct?
What makes an interface a functional interface?
Which built-in interface is a classic example of a marker interface?
Why might you define your own marker interface?
Which is a valid declaration of a functional interface for processing orders?
Order the steps to define and use an abstract class for reporting different file formats
Drag and drop to reorder, or use the arrows.
Order the steps to create and use an interface for email notification sending
Drag and drop to reorder, or use the arrows.
What is the output of this code using an abstract class reference?
1abstract class Shape {
2 abstract double area();
3}
4class Square extends Shape {
5 private double side;
6 Square(double side) { this.side = side; }
7 double area() { return side * side; }
8}
9public class Main {
10 public static void main(String[] args) {
11 Shape s = new Square(3);
12 System.out.println(s.area());
13 }
14}What is the output when a class implements an interface with a default method?
1interface Greeter {
2 default String greet() { return "Hello"; }
3}
4class FriendlyGreeter implements Greeter {
5}
6public class Main {
7 public static void main(String[] args) {
8 Greeter g = new FriendlyGreeter();
9 System.out.println(g.greet());
10 }
11}What is the output of calling a static interface method?
1interface MathUtils {
2 static int triple(int x) { return x * 3; }
3}
4public class Main {
5 public static void main(String[] args) {
6 System.out.println(MathUtils.triple(4));
7 }
8}What is the output when a default method uses a private helper in an interface?
1interface Formatter {
2 private String wrap(String s) { return "[" + s + "]"; }
3 default String formatName(String name) { return wrap(name.toUpperCase()); }
4}
5class NameFormatter implements Formatter { }
6public class Main {
7 public static void main(String[] args) {
8 Formatter f = new NameFormatter();
9 System.out.println(f.formatName("alice"));
10 }
11}What is the output when using a lambda with a functional interface?
1@FunctionalInterface
2interface Converter {
3 String convert(int value);
4}
5public class Main {
6 public static void main(String[] args) {
7 Converter c = v -> "Value:" + (v + 2);
8 System.out.println(c.convert(5));
9 }
10}Find the bug in this code using an interface as a functional interface
Click on the line(s) that contain the bug.
@FunctionalInterfaceinterface Task { void run(); void stop();}public class Main { public static void main(String[] args) { Task task = () -> System.out.println("Running"); }}Find the bug in this code using a default method and a private helper in an interface
Click on the line(s) that contain the bug.
import java.util.Arrays;interface Statistics { default double average(double[] data) { return sum(data) / data.length; } private static double sum(double[] data) { return Arrays.stream(data).sum(); }} Match each interface feature with its primary purpose
Click an item on the left, then click its match on the right. Click a matched item to unmatch.
Match each abstraction concept to a realistic use case
Click an item on the left, then click its match on the right. Click a matched item to unmatch.
Complete the code for an interface with a default method that calculates the area of a circle using a provided radius
public interface CircleCalculator { double radius(); default double () { return Math.PI * * ; }}Click an option to fill blank 1:
Complete the functional interface and its lambda usage to log a message with a prefix
@FunctionalInterfaceinterface Logger { void (String msg);}public class Main { public static void main(String[] args) { Logger logger = m -> System.out.println("[INFO] " + m); logger.("Started"); }}Click an option to fill blank 1:
Complete the interface to add a static factory method that creates a Greeting functional interface
@FunctionalInterfaceinterface Greeting { void say(String name); static Greeting (String prefix) { return n -> System.out.println(prefix + ", " + n); }}public class Main { public static void main(String[] args) { Greeting g = Greeting.("Welcome"); g.say("Sam"); }}Click an option to fill blank 1:
Complete the marker interface usage to control which entities are exportable
interface { }class Product implements { String name;}class AuditService { boolean canExport(Object o) { return o instanceof ; }}Click an option to fill blank 1:
Click the line that calls a default method from an interface reference
Click on the line to select.
interface Printer { default void print(String msg) { System.out.println("PRINT: " + msg); }}class ConsolePrinter implements Printer { }public class Main { public static void main(String[] args) { Printer p = new ConsolePrinter(); p.print("Ready"); }} Click the line that checks for a marker interface implementation
Click on the line to select.
interface Cacheable { }class Session implements Cacheable { }class Logger { }public class Main { public static void main(String[] args) { Object o = new Session(); boolean result = o instanceof Cacheable; System.out.println(result); }}