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..
Given: package ocjap; class Student{ String name; public Student(String name){ this.name=name; } } public class Test86 { public static void main(String[] args) { Student[] students=new Student[3]; students[1]=new Student("Richard"); students[2]=new Student("Donald"); for (Student s : students) { System.out.println(""+s.name); } } } What is the result? A. null Richard Donald B. Richard Donald C. ..
package ocjap; public class Arr64 { public static void main(String[] args) { int numbers[]; numbers=new int[2]; numbers[0]=10; numbers[1]=20; numbers=new int[4]; numbers[2]=30; numbers[3]=40; for(int x:numbers){ System.out.print(" "+x); } } } What is the result? A. 10 20 30 40 B. 0 0 30 40 C. Compliation fails. D. An exception is thrown at runtime. 정답: B 해설: int 배열이기 때문에 0으로 초기화 된다. 때문에 new int[..
- Total
- Today
- Yesterday
- 포인터
- 파싱
- JDBC
- 인포믹스
- xe addon
- 프로씨
- C
- 파이썬
- ocjap
- 스크래핑
- 이클립스
- 자바
- C언어
- 문자열
- XE3
- MySQL
- webix
- KG
- 플러터
- 자바 smtp
- 라이믹스 모듈
- 오라클
- xe애드온
- XE
- EC
- esql
- ocajp
- proc
- php
- Python
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |