File tree Expand file tree Collapse file tree 1 file changed +37
-1
lines changed
Expand file tree Collapse file tree 1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -525,7 +525,7 @@ public class MethodLocalVSInner {
525525}
526526{% endhighlight %}
527527
528- This is an interesting [ question] ( http://stackoverflow.com/questions/29620714/method-local-inner-class-vs-inner-class ) ,
528+ This is an [ interesting question] ( http://stackoverflow.com/questions/29620714/method-local-inner-class-vs-inner-class ) ,
529529so think and determine the output?
530530
531531A. inner
@@ -534,3 +534,39 @@ C. middle
534534D. Compilation fails
535535E. An exception is thrown at runtime
536536
537+ __ Q4.__
538+
539+ {% highlight java linenos %}
540+ class Car {
541+ class Engine {
542+ // insert code here
543+ }
544+
545+ public static void main(String[] args) {
546+ new Car().go();
547+ }
548+
549+ void go() {
550+ new Engine();
551+ }
552+
553+ void drive() {
554+ System.out.println("hi");
555+ }
556+ }
557+ {% endhighlight %}
558+
559+ Which, inserted independently at line 3, produce the output "hi"? (Choose all that apply.)
560+
561+ A. { Car.drive(); }
562+ B. { this.drive(); }
563+ C. { Car.this.drive(); }
564+ D. { this.Car.this.drive(); }
565+ E. Engine() { Car.drive(); }
566+ F. Engine() { this.drive(); }
567+ G. Engine() { Car.this.drive(); }
568+
569+ __ Q5.__
570+
571+
572+
You can’t perform that action at this time.
0 commit comments