Question: The program
Problem.java doesn't compile. What do you need to do to make it compile? Why?
Answer: Delete static in front of the declaration of the Inner class. An static inner class does not have access to the instance fields of the outer class. See
ProblemSolved.java.
Use the Java API documentation for the
Box class (in the javax.swing package) to help you answer the following questions.
Question: What static nested class does Box define?
Answer: Box.Filler
Question: What inner class does Box define?
Answer: Box.AccessibleBox
Question: What is the superclass of Box's inner class?>
Answer: [java.awt.]Container.AccessibleAWTContainer
Question: Which of Box's nested classes can you use from any class?
Answer: Box.Filler
Question: How do you create an instance of Box's Filler class?
Answer: new Box.Filler(minDimension, prefDimension, maxDimension)
Exercise: Get the file
Class1.java. Compile and run Class1. What is the output?
Answer: InnerClass1: getString invoked.
InnerClass1: getAnotherString invoked.