3. Interfaces. Based on Reges self-check 9.5.20. (10 points)
Consider the following interface and class:
public interface I {
public void m1();
public void m2();
}
public class C implements I {
// code for class C
}
3.1. What must be true about the code for class C in order for that code to compile successfully? (2
points)
3.2. Create I.java, C.java, and a main program class, to meet the following requirements:
3.2.1. Your name and today's date is a comment on the first line of all three files.
3.2.2. I.java has exactly the code listed in the example.
3.2.3. C.java implements methods m1() and m2():
method m1() outputs "This is method m1" to the console.
method m2() outputs "This is method m2" to the console.
3.2.4. The main program instantiates class C and calls method m1 and m2 of the instantiated
object.
If you would prefer to use inline classes for this lab, that is acceptable, but the interface and
implementation class must still be named I and C respectively.
Rubric:
Student name and date is in a comment on the first line of the programs: -5 points if fails
Question 1: 2 points
Three .java files: 3 points
I.java: 1 point
C. java: 2 points
Main java program: 2 points
Please paste a screenshot of a successful program run, and copy-and-paste the source code from all
three .java files, here: