File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -608,4 +608,37 @@ D. Compilation fails due to multiple errors
608608E. Compilation fails due only to an error on line 4
609609F. Compilation fails due only to an error on line 7
610610
611+ __ Q6.__
612+
613+ {% highlight java linenos %}
614+ class OuterClassAccess {
615+ private int size = 7;
616+ private static int length = 3;
617+
618+ public static void main(String[] args) {
619+ new OuterClassAccess().go();
620+ }
621+
622+ void go() {
623+ int size = 5;
624+ System.out.println(new Inner().adder());
625+ }
626+
627+ class Inner {
628+ int adder() {
629+ return size * length; // inner class can access static members of outer class
630+ }
631+ }
632+ }
633+ {% endhighlight %}
634+
635+ What is the result?
636+
637+ A. 15
638+ B. 21
639+ C. An exception is thrown at runtime
640+ D. Compilation fails due to multiple errors
641+ E. Compilation fails due only to an error on line 4
642+ F. Compilation fails due only to an error on line 5
643+
611644
You can’t perform that action at this time.
0 commit comments