QUESTION 40자격증/OCJP_ExamB2018. 7. 11. 14:12
Table of Contents
반응형
QUESTION 40
Given:
1. public class Pass2 {
2. public void main(String [] args) {
3. int x = 6;
4. Pass2 p = new Pass2();
5. p.doStuff(x);
6. System.out.print(" main x = " + x);
7. }
8.
9. void doStuff(int x) {
10. System.out.print(" doStuff x = " + x++);
11. }
12. }
And the command-line invocations:
javac Pass2.java java Pass2 5
What is the result?
A. Compilation fails.
B. An exception is thrown at runtime.
C. doStuff x = 6 main x = 6
D. doStuff x = 6 main x = 7
E. doStuff x = 7 main x = 6
F. doStuff x = 7 main x = 7
Solution : B
plus imformation
1. public class Pass2 {
2. public void main(String [] args) { // main문 앞에 static이 빠져있다.
반응형
'자격증 > OCJP_ExamB' 카테고리의 다른 글
QUESTION 42 (0) | 2018.07.13 |
---|---|
QUESTION 41 (0) | 2018.07.11 |
QUESTION 39 (0) | 2018.07.11 |
QUESTION 38 (0) | 2018.07.11 |
QUESTION 36 (0) | 2018.07.10 |
@IT grow. :: IT grow.
#IT #먹방 #전자기기 #일상
#개발 #일상