Answer: initialize the inner class : Questions « Object Oriented « SCJP






middle








6.14.Questions
6.14.1.An anonymous inner class must appear inside a block of code(True/False).
6.14.2.Answer: anonymous inner class definition
6.14.3.Anonymous inner classes may not call the enclosing class' synchronized methods(True/False)/
6.14.4.Answer: anonymous class and synchronized methods
6.14.5.Anonymous inner classes may only call final methods of the enclosing class(True/False).
6.14.6.Answer: Anonymous inner classes and final methods
6.14.7.Anonymous inner classes may only read and write final variables of the enclosing class(True/False).
6.14.8.Answer: Anonymous inner classes and final variables
6.14.9.Will the following code compile(enum and object)?
6.14.10.Answer: enum and object
6.14.11.Will the following code compile(Enum and object conversion)?
6.14.12.Answer: Enum and object conversion
6.14.13.Will the following code compile(Enum and object conversion and casting)?
6.14.14.Answer: Enum and object conversion and casting
6.14.15.Will the following code compile(enum casting)?
6.14.16.Answer: enum casting
6.14.17.An anonymous inner class may implement at most one interface(True/False).
6.14.18.Answer: anonymous inner class and interface
6.14.19.An anonymous inner class may extend a parent class other than Object(True/False).
6.14.20.Answer: anonymous inner class and parent class
6.14.21.An anonymous inner class that implements one interface may extend a parent class other than Object(True/False).
6.14.22.Answer: anonymous inner class and interface and parent class
6.14.23.Which methods return an enum constant's name?
6.14.24.Answer: enum and constant value
6.14.25.For a static nested class, you must have a reference to an instance of the enclosing class in order to instantiate it (True/False)
6.14.26.Answer: static nested class
6.14.27.For a static nested class, it does not have access to non-static members of the enclosing class(True/False)
6.14.28.Answer: static nested class(2)
6.14.29.For a static nested class, its variables and methods must be static(True/False)
6.14.30.Answer: static nested classes(3)
6.14.31.For a static nested class, if the outer class is named MyOuter, and the nested class is named MyInner, it can be instantiated using new MyOuter.MyInner();(True/False)
6.14.32.Answer: static nested classes(4)
6.14.33.For a static nested class, it must extend the enclosing class(True/False)
6.14.34.Answer: static nested class(5)
6.14.35.Which create an anonymous inner class from within class Bar?
6.14.36.Answer: anonymous inner class
6.14.37.A method-local inner class must be marked final(True/False)
6.14.38.Answer: method local inner class(1)
6.14.39.A method-local inner class can be marked abstract(True/False)
6.14.40.Answer: method local inner class(2)
6.14.41.A method-local inner class can be marked public
6.14.42.Answer: method local inner class(3)
6.14.43.A method-local inner class can be marked static(True/False)
6.14.44.Answer: method local inner class(4)
6.14.45.A method-local inner class can access private members of the enclosing class(True/False)
6.14.46.Answer: method local inner class(5)
6.14.47.What is the result(inner class)?
6.14.48.Result: inner class
6.14.49.What is the result (inner class(2))?
6.14.50.Answer: inner class(2)
6.14.51.What is the result(abstract class)?
6.14.52.Answer: using abstract class
6.14.53.What is the result(initialize the inner class)?
6.14.54.Answer: initialize the inner class
6.14.55.What is the result(extends inner class)?
6.14.56.Answer: extends inner class
6.14.57.What is the result(reference variable in outter class)?
6.14.58.Answer: reference variable in outter class
6.14.59.What is the result(Arrays.sort)?
6.14.60.Answer: Arrays.sort