017-004-008
Extending and Implementing Multiple Interfaces
Hard
Problem Description
Extending and Implementing Multiple Interfaces
In this problem, you will create a program that defines Readable and Writable interfaces, builds a ReadWritable interface extending both, implements it with a TextFile class, and displays the results of read and write operations to standard output.
Learning Objective: Understand the pattern where one interface extends multiple interfaces
Overview
Define Readable and Writable interfaces, then ReadWritable extends both. TextFile implements ReadWritable.
Specifications
- Declare
String read()inReadable - Declare
void write(String data)inWritable ReadWritableextends bothReadableandWritableTextFileimplementsReadWritable:- constructor accepts initial content
read()returns stored contentwrite(String data)overwrites content
- In main, create TextFile and call read, write, read in order
Output Format
Read: Hello
Read: World
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up