Home Tutorial Java Scjp Part3 SCJP Module-3 Question-1

 
 

Share on Google+Share on Google+
SCJP Module-3 Question-1
Posted on: July 9, 2010 at 12:00 AM
Advertisement
The given example checks your knowledge of access specifier in Java and also heps in preparation for SCJP exam.

Given a sample code:

1 public class Test {
2 public static void main(String[] args) {
3 new OuterClass();
}}

4 class OuterClass {
5 private int x = 9;

6 public OuterClass() {
7 InnerClass inner = new InnerClass();
8 inner.innerMethod();
}

9   class InnerClass {
10 public void innerMethod() {
11 System.out.println(x);
}}}

What will be the result of above code ?

(1) Prints 9
(2) Error during compilation at line 3
(3) Error during compilation at line 5
(4) Error during compilation at line 7

Answer:

(1)

Advertisement

Related Tags for SCJP Module-3 Question-1:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 9, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com