Java Reference
In-Depth Information
Self-Test Exercises (continued)
9. Will the following program compile? If it does compile will it run? Interface1
and Interface2 were defined in the previous subsection.
public class MyClass
implements Interface1, Interface2
{
public static void main(String[] args)
{
System.out.println("Hello");
}
}
10. Will the following program compile? If it does compile will it run? InterfaceA
and InterfaceB were defined in the previous subsection.
public class YourClass
implements InterfaceA, InterfaceB
{
public String getStuff()
{
return "one";
}
}
11. Will the following two interfaces and the following program class compile? If
they compile will the program run with no error messages?
public interface InterfaceA
{
public int getStuff();
}
public interface InterfaceOtherB
{
public String getStuff(String someStuff);
}
public class OurClass
implements InterfaceA, InterfaceOtherB
{
private int intStuff = 42;
public static void main(String[] args)
{
OurClass object = new OurClass();
System.out.println(object.getStuff()
+ object.getStuff(" Hello"));
}
Search WWH ::




Custom Search