|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
1. The program
Problem.javadoesn't compile. What do you need to do to make it compile? Why?
2. Use the 5.0 API documentation for the
Boxclass (in the
javax.swingpackage) to help you answer the following questions.a. What static nested class does
Boxdefine?
b. What inner class doesBoxdefine?
c. What is the superclass ofBoxs inner class?
d. Which ofBoxs nested classes can you use from any class?
e. How do you create an instance ofBoxsFillerclass?
Check your answers.1. Get the file
Class1.java.
a. Compile and run
Class1. What is the output?b. Create a file called
Class2.javathat defines subclasses of bothClass1and its inner class,InnerClass1. (Call the subclassesClass2andInnerClass2, respectively.)InnerClass2should override thegetAnotherStringmethod to return"InnerClass2 version of getAnotherString invoked".Class2should define one constructor and one method:
- A no-argument constructor that initializes the inherited
icinstance variable to be an instance ofInnerClass2- A main method that creates an instance of
Class2and invokesdisplayStringson that instanceWhat is the output when you run
Class2?
|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.