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

 
 

SCJP Module-3 Question-1
Posted on: July 9, 2010 at 12:00 AM
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)

Related Tags for SCJP Module-3 Question-1:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.