Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
1. The program
Problem.java
doesn't compile. What do you need to do to make it compile? Why?2. Use the 5.0 API documentation for the
Box
class (in thejavax.swing
package) to help you answer the following questions.a. What static nested class does
Box
define?
b. What inner class doesBox
define?
c. What is the superclass ofBox
s inner class?
d. Which ofBox
s nested classes can you use from any class?
e. How do you create an instance ofBox
sFiller
class?
Check your answers.1. Get the file
Class1.java
.a. Compile and run
Class1
. What is the output?b. Create a file called
Class2.java
that defines subclasses of bothClass1
and its inner class,InnerClass1
. (Call the subclassesClass2
andInnerClass2
, respectively.)InnerClass2
should override thegetAnotherString
method to return"InnerClass2 version of getAnotherString invoked"
.Class2
should define one constructor and one method:
- A no-argument constructor that initializes the inherited
ic
instance variable to be an instance ofInnerClass2
- A main method that creates an instance of
Class2
and invokesdisplayStrings
on 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.