|
NOTA: La traducción de esta documentación es un esfuerzo personal y voluntario, no es un documento oficial de Sun Microsystems
ni Oracle ni está patrocinado por ninguna de estas empresas. Los documentos originales (en inglés) están disponibles en:
http://java.sun.com/docs/books/tutorial/.
Dirija cualquier comentario, petición, felicitación, etc. a tutorialesjava_@RROBA_codexion.com. |
Si desea ayudar a mantener en funcionamiento esta web, colaborar con la traducción de estos documentos o necesita que se traduzca algĂșn capĂtulo en concreto puede realizar una donación directa mediante Paypal:
|
Question 1: The programProblem.javadoesn't compile. What do you need to do to make it compile? Why?
Answer 1: Deletestaticin front of the declaration of theInnerclass. An static inner class does not have access to the instance fields of the outer class. SeeProblemSolved.java.
Question 2: Use the Java API documentation for theBoxclass (in thejavax.swingpackage) to help you answer the following questions.a. What static nested class doesBoxdefine?
Answer 2a:Box.Fillerb. What inner class doesBoxdefine?
Answer 2b:Box.AccessibleBoxc. What is the superclass ofBoxs inner class?
Answer 2c:[java.awt.]Container.AccessibleAWTContainerd. Which ofBoxs nested classes can you use from any class?
Answer 2d:Box.Fillere. How do you create an instance ofBoxsFillerclass?
Answer 2e:new Box.Filler(minDimension, prefDimension, maxDimension)
Exercise 1: Get the fileClass1.java.a. Compile and runClass1. What is the output?
Answer:InnerClass1: getString invoked.
InnerClass1: getAnotherString invoked.