class C2 { public void displayC2() { System.out.print("C2"); } } interface I { public void displayI(); } class C1 extends C2 implements I { public void displayI() { System.out.print("C1"); } } public class Extend76 { public static void main(String[] args) { C2 obj1=new C1(); I obj2=new C1(); C2 s = obj2; I t=obj1; t.displayI(); s.displayC2(); } } What is the result? A. C2C2 B. C1C2 C. C1C1 D. Co..
public class Switch78 { public static void main(String[] args) { int wd=0; String days[]= {"sun","mon","wed","sat"}; for(String s:days) { switch(s) { case "sat": case "sun": wd-=1; break; case "mon": wd++; case "wed": wd+=2; } } System.out.println(wd); } } What is the result? A. 3 B. 4 C. -1 D. Compilation fails. 정답: A 결과: 3 해설: 아래처럼 찍어보면 이해가 쉽다. switch case를 쓸때 주의할 점이 break가 없는 case에서는 아래 case가..
Given the code fragment: import java.util.ArrayList; public class List63 { public static void main(String[] args) { ArrayList points = new ArrayList(); points.add(1); points.add(2); points.add(3); points.add(4); points.add(null); points.remove(2); points.remove(null); System.out.println(points); } } What is the result? A. A NullPointerException is thrown at runtime. B. [1,2,4] C. [1,2,4,null] D...
Given: public class Product{ int id; String name; public Product(int id, String name){ this.id=id; this.name=name; } } public class Class47 { public static void main(String[] args) { Product p1=new Product(101,"Pen"); Product p2=new Product(101,"Pen"); Product p3=p1; boolean ans1=p1==p2; boolean ans2=p1.name.equals(p2.name); System.out.print(ans1 + ":" + ans2); } } What is the result? A. true:tr..
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: 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
- 이클립스
- XE3
- proc
- Python
- 프로씨
- ocjap
- 자바 smtp
- php
- xe애드온
- EC
- esql
- C언어
- 파이썬
- ocpjp
- webix
- 오라클
- 문자열
- xe addon
- C
- 스크래핑
- 인포믹스
- JDBC
- 파싱
- 포인터
- 자바 셀레니움
- MySQL
- 자바
- KG
- XE
- ocajp
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |