This lab is designed to give you some practice dealing with the four different types of inner classes. Don’t expect the example to make any intuitive sense. In a real-life scenario, you would not have class names like Outer, Inner and StaticMan. At the end of these 12 steps you should have a single file called Outer.java that compiles with no errors. It is recommended that you print this out before attempting the lab.
private String inString
= "Outer inString";
private String outString
= "Outer outString";
public interface Printable
{
public void
print();
}
public class Inner {
private String
inString = "Inner inString";
public String
getInString() { return this.inString; }
public String
getOutString() { return outString; }
}
public static class StaticMan
{
public void
method1() {}
void method2()
{}
private void
method3() {}
protected
void method4() {}
public String
getOutString() {
String result = "";
result = outString;
return result;
}
}
}
i.getInString():
___________________
i.getOutString():
___________________
method1(): __________________________________________________________
method2(): __________________________________________________________
method3(): __________________________________________________________
method4(): __________________________________________________________
_____________________________________________________________________
class MInner {
public void method()
{
System.out.println(
outString );
}
}
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
p.print();