Which are true? (Choose all that apply.)
A. The output could contain 30
B. The output could contain @bf73fa
C. The output could contain DIAMONDS
D. Compilation fails due to an error on line 6
E. Compilation fails due to an error on line 7
F. Compilation fails due to an error on line 8
Ans: A and B
But on line 13 points is accessed wch is private then
shudnt the code fail to compile?
OCPJP 6-100%; Preparing for GATE11
Gari Jain
Ranch Hand
Joined: Jun 29, 2009
Posts: 100
posted
0
QUESTION2:
What is the result?
A. 5 7
B. 5 8
C. 8 7
D. 8 8
E. Compilation fails
F. An exception is thrown at runtime
Ans: E
The parameter declared on line 9 is valid (although ugly), but the variable
name ouch cannot be declared again on line 11 in the same scope as the declaration on
line 9.
but isnt ouch declared inside for inside another scope?
About question 1. The main method is in the same class thus has access.
About question 2. No that is not true. Because the method parameter ouch is still visible in the for loop and cannot be hidden.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.