here is the question
public interface Material
{
}
public interface Instrument{
public void play();
}
public class Piano implements Instrument, Material {
public void play() {
System.out.println ("Playing the piano");
}
public static void main(String[] args) {
Instrument inst = new Piano();
inst.play();
}
}
Answers
1. Compilation succeeds, no output is produced.
2. Compilation succeeds, the output is Playing the Piano
3. Compilation fails, Piano cannot implement 2 interfaces
4. Compilation fails, interface Material does not have any methods defined
5. Compilation fails, interface Instrument does not have an implementation for the play() method
the answer is 2,
but i am getting the error
Piano.java:1: class Material is public, should be declared in a file named Mater
ial.java
public interface Material
^
Piano.java:4: class Instrument is public, should be declared in a file named Ins
trument.java
public interface Instrument{
^
2 errors
can u help me?
thanks...