QUESTION 38자격증/OCJP_ExamB2018. 7. 11. 00:09
Table of Contents
반응형
QUESTION 38
Given:
01. public static void test(String str) {
02. int check = 4;
03. if (check = str.length()) {
04. System.out.print(str.charAt(check -= 1) +", ");
05. } else {
06. System.out.print(str.charAt(0) + ", ");
07. }
08. }
and the invocation:
test("four");
test("tee");
test("to");
What is the result?
A. r, t, t,
B. r, e, o,
C. Compilation fails.
D. An exception is thrown at runtime.
Solution : C
plus imformation
Main.java:3:
incompatible types
found : int
required: boolean
if (check = str.length()) { // 자료형 불일치 , check = 정수형 , 조건문은 boolean 타입원함
^ 1 error
반응형
'자격증 > OCJP_ExamB' 카테고리의 다른 글
QUESTION 40 (0) | 2018.07.11 |
---|---|
QUESTION 39 (0) | 2018.07.11 |
QUESTION 36 (0) | 2018.07.10 |
QUESTION 35 (0) | 2018.07.10 |
QUESTION 34 (0) | 2018.07.10 |
@IT grow. :: IT grow.
#IT #먹방 #전자기기 #일상
#개발 #일상