티스토리 뷰
Given the code fragment:
package ocjap;
public class Arr18 {
public static void main(String[] args) {
/* insert code here */
int array[2];
array[0]=10;
array[1]=20;
System.out.print(array[0]+":"+array[1]);
}
}
Which code fragment, when inserted at line 3, enables the code to print 10:20?
A. int[] array=new int[2];
B. int[] array;
array=int[2];
C. int array=new int[2];
D. int array[2];
정답: A
해설:
자바의 배열 선언방법
B번은 아래와 같은 오류가 발생.
The type of the expression must be an array type but it resolved to Class
C번 오류
Type mismatch: cannot convert from int[] to int
D번 오류
Syntax error on token "2", delete this token
'ocajp 자격증 (Oracle Certified Associate Ja' 카테고리의 다른 글
자바 ocjap 문제 해설 - do while (0) | 2020.02.24 |
---|---|
자바 ocjap 문제 해설 - Switch Case (0) | 2020.02.24 |
자바 ocjap 문제 및 해설 - 배열 (0) | 2020.02.23 |
자바 ocjap 문제 및 해설 - Exception (0) | 2020.02.23 |
자바 ocjap 문제 및 해설 - 배열 86 (0) | 2020.02.23 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 오라클
- php
- XE3
- 파싱
- xe애드온
- 플러터
- MySQL
- 포인터
- ocjap
- 인포믹스
- 자바 smtp
- xe addon
- XE
- ocajp
- 라이믹스 모듈
- C
- KG
- Python
- JDBC
- C언어
- 프로씨
- 스크래핑
- esql
- 문자열
- proc
- webix
- 파이썬
- 자바
- 이클립스
- EC
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
글 보관함