← All Exercises
Java Interface Default Methods
intermediatejava
Background
Default methods (Java 8+) allow adding methods to interfaces without breaking existing implementations.
Problem
Create a StringProcessor interface with a default process method that chains normalize and format, and a static factory method.
Input
A string to process through the interface.
Output
A processed string after normalization and formatting.
Sample tests
Sample 1
Input: " Hello World "
Expected: "hello world" (trimmed and lowercased)
Your solution
Learning objective
Learn interface default methods, static factory methods in interfaces, and API evolution patterns.