Skip to content

Commit f885d25

Browse files
author
Ram swaroop
committed
added content
1 parent fd9375d commit f885d25

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

_posts/2015-08-20-nested-classes.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff 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),
529529
so think and determine the output?
530530

531531
A. inner
@@ -534,3 +534,39 @@ C. middle
534534
D. Compilation fails
535535
E. 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+

0 commit comments

Comments
 (0)