ocajp에는 2차월 배열 문제가 많이 나온다. 그래서 자바 2차원 배열에 관해 정확히 이해하고 가는게 좋다. 2차원 배열에 대해 알려드릴게요. 바로 이전 포스팅에서 보셨던 배열이 1차원 배열이에요. 2차원 배열은 값을 더 많이 효과적으로 담을 수 있어요. 이런 2차원 이상의 배열을 다차원 배열이라고 하는데 실질적으로 2차원 배열 이상으로는 잘 사용되지 않아요. 1차원과 2차원이 무엇이냐면 1차원 배열에서는 값을 1번만 담아요. 그런데 2차원 배열은 1차원 배열에 값을 더 담을 수 있어요. 예를 들어볼게요. int[][] arr = new int[3][4]; 3개의 배열 안에 각각 4개씩 더 담을 수 있는 거죠. 이것을 보기 쉽게 변경한다면 이런 형태가 돼요. 따라서 int[3][4]이면 3은 세로 길이..
Given class Base{ public void test() { System.out.println("Base "); } } class DerivedA extends Base{ public void test() { System.out.println("DerivedA "); } } class DerivedB extends DerivedA { public void test() { System.out.println("DerivedB "); } public static void main(String[] args) { Base b1=new DerivedB(); Base b2=new DerivedA(); Base b3=new DerivedB(); b1=(Base)b3; Base b4=(DerivedA)b3; b..
Given: class A{ public A() { System.out.print("A "); } } class B extends A{ public B() { System.out.print("B "); } } class C extends B{ public C() { System.out.print("C "); } public static void main(String[] args) { C c=new C(); } } What is the result? A. C B A B. C C. A B C D. Compilation fails at line n1 and line n2 정답: C 해설: extends 로 확장하면서 생성자를 호출 시키고 있다. 쉽게 생각해서 로직을 실행시키기 전에 순서로 따지면 extends..
Given: public class Operator30 { public static void main(String[] args) { System.out.println("5+2="+3+4); System.out.println("5+2="+(3+4)); } } What is the result? A. 5+2=34 5+2=34 B. 5+2+3+4 5+2=7 C. 7=7 7+7 D. 5+2=34 5+2=7 정답: D 해설: 괄호로 인해 숫자는 덧셈 연산이 되고 나머지는 스트링 뒤에 + 이면 문자열을 붙인다.
Given the following main method: public class DoWhile14 { public static void main(String[] args) { int num=5; do { System.out.print(num--+" "); }while(num==0); } } What is the result? A. 5 4 3 2 1 0 B. 5 4 3 2 1 C. 4 2 1 D. 5 E. Nothing is printed 정답: D 해설: do while은 do를 먼저 실행하고 while문 이 참이면 do를 계속 실행한다. while문에 거짓이면 실행안한다. 여기서는 do를 먼저 실행해서 5를 출력하고 while문에서 num이 0이 아니니까 빠져나간다. 결과: 5
Given the code fragment: public class Switch13 { public static void main(String[] args) { boolean opt=true; switch(opt) { case true: System.out.print("True"); break; default: System.out.print("***"); } System.out.println("Done"); } } Which modification enables the code fragment to print TrueDone? A. Replace line 5 With String opt="true"; Replace line 7 with case "true": B. Replace line 5 with bo..
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 해설: ..
20 Which three are advatages of the Java exception mechanism? (Choose three.) A. Improves the program structure because the error handing code is separated from the normal program function B. Provides a set of standard exceptions that covers all the possible errors C. Improves the program structure because the programmer can choose where to handle exceptions D. Improves the program structure bec..
- Total
- Today
- Yesterday
- C
- JDBC
- ocjap
- 파싱
- 자바 smtp
- ocajp
- MySQL
- 포인터
- 오라클
- xe addon
- 파이썬
- Python
- XE3
- 라이믹스
- 자바
- C언어
- EC
- 문자열
- xe애드온
- 인포믹스
- XE
- 프로씨
- proc
- 이클립스
- 스크래핑
- webix
- 플러터
- php
- esql
- KG
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
