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가..
아 switch case는 if else 처럼 잘 쓰지 않아서 가끔 볼때마다 헷갈린다.. break가 없을 경우 case 아래를 무조건 실행하는게 좀 이해가 안간다... 암튼.. switch문은 어떤 변수의 값에 따라서 문장을 실행할 수 있도록 하는 제어문이다. switch문에서 사용하는 키워드는 switch, case, default, break 이다. switch문 switch(변수){ case 값1 : 실행문; break; case 값2 : 실행문; break; default; } int value = 1; switch(value){ case 1: System.out.println("1"); break; case 2: System.out.println("2"); break; case 3 : Syst..
public class Array84 { public static void main(String[] args) { int array[]= {10,20,30,40,50}; int x=array.length; /* line n1 */ } } A. while(x>0) { x--; System.out.print(array[x]); } B. do { x--; System.out.print(array[x]); }while(x>=0); C. while(x>=0) { System.out.print(array[x]); x--; } D. do { System.out.print(array[x]); --x; }while(x>=0); E. while(x>0) { System.out.print(array[--x]); } Whic..
class Student{ String name; public Student(String name) { this.name=name; } } public class Array86 { 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. Compilation fails...
Given the code fragment: public class Arr67 { public static void main(String[] args) { int[] stack={10,20,30}; int size=3; int idx=0; /* line n1 */ System.out.print("The Top element: "+stack[idx]); } } Which code fragment, inserted at line n1, prints The Top element: 30? A. do{ idx++; System.out.println("idx: "+idx); }while(idx>=size); B. while(idx
배열이란 동일한 자료형으로 선언된 데이터 공간을 메모리 상에 연속적으로 나열하여 데이터 관리의 효율성을 높이는 것입니다. 변수는 한개의 데이터만 저장할 수 있습니다. 따라서 저장해야 할 데이터의 수가 많아지면 그만큼 많은 양의 변수를 선언해줘야하는 비효율성이 발생하죠. 그렇기에 좀 더 효율적인 방법이 필요한데 이것이 배열입니다. 배열은 같은 타입의 데이터를 연속된 공간에 나열시키고 각 데이터에 인덱스(index)를 부여해 놓은 자료구조입니다. 여러가지 배열 선언 //int 타입 배열 선언 int[] i_array; int i_array[]; //배열 생성후 초기화하면 배열의 주소가 할당된다. int[] i_array = new int[8]; //초기값 0 String[] s_array = new Stri..
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..
- Total
- Today
- Yesterday
- 플러터
- esql
- proc
- 파싱
- MySQL
- XE
- 포인터
- EC
- KG
- 이클립스
- webix
- ocjap
- C언어
- 자바
- 자바 smtp
- 파이썬
- 스크래핑
- xe애드온
- php
- 문자열
- C
- JDBC
- 라이믹스
- Python
- 프로씨
- ocajp
- xe addon
- 인포믹스
- 오라클
- XE3
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
