Microsoft Word - java18-1-final-answer.doc

Size: px
Start display at page:

Download "Microsoft Word - java18-1-final-answer.doc"

Transcription

1 기말고사 담당교수 : 단국대학교응용컴퓨터공학박경신 답은반드시답안지에기술할것. 공간이부족할경우반드시답안지몇쪽의뒤에있다고명기한후기술할것. 그외의경우의답안지뒤쪽이나연습지에기술한내용은답안으로인정안함. 답에는반드시네모를쳐서확실히표시할것. 답안지에학과, 학번, 이름외에본인의암호 (4자리숫자 ) 를기입하면성적공고시학번대신암호를사용할것임. 1. 다음 sub1 과 sub2 의실행결과가같도록, sublist 메소드내부의코드를완성하라. (10 점 ) public static int[] sublist(int[] list, int fromindex, int toindex) { int size = toindex fromindex; int[] result = new int[size]; for (int i = 0; i < size; i++) { result[i] = list[fromindex + i]; return result; public static List<Integer> sublist(list<integer> list, int fromindex, int toindex) { List<Integer> result = new ArrayList<Integer>(); for (int i = fromindex; i < toindex; i++) { result.add(list.get(i)); return result; public static void main(string[] args) { int[] dataarray = {7, 5, 8, 5, 9, 7, 2, 3; int[] sub1 = sublist(dataarray, 2, 5); System.out.println("sub1 = " + Arrays.toString(sub1)); // sub1 = [8, 5, 9] List<Integer> datalist = Arrays.asList(7, 5, 8, 5, 9, 7, 2, 3); List<Integer> sub2 = sublist(datalist, 2, 5); System.out.println("sub2 = " + Arrays.toString(sub2.toArray())); // sub2 = [8, 5, 9] 1/9

2 2. 다음코드의실행결과를적어라 (parameter passing 에유의할것 ). (10 점 ) public static int mystery(int n, int[] numbers) { n += 100; numbers[2] ; System.out.println(n + " " + Arrays.toString(numbers)); return numbers[1] * 2; public static void mystery(int[] x, int[] y) { int[] t = x; x = y; y = t; System.out.println(Arrays.toString(x) + " " + Arrays.toString(y)); public static void mystery(int[] list) { for (int i = 1; i < list.length 1; i++) { if (list[i] <= list[i + 1]) { list[i + 1] = i * 2; public static void main(string[] args) { int a = 4; int b = 8; int[] data = {5, 10, 15; a = mystery(b, data); // 108 [5, 10, 14] System.out.println(a + " " + b + " " + Arrays.toString(data)); // 20 8 [5, 10, 14] System.out.println(); int[] x = {1, 2; int[] y = {3, 4, 5; mystery(x, y); // [3,4,5] [1,2] System.out.println(Arrays.toString(x) + " " + Arrays.toString(y)); // [1,2] [3,4,5] System.out.println(); int[] data1 = {4, 1, 3; int[] data2 = {2, 1, 3, 2; int[] data3 = {1, 1, 1, 1, 8; mystery(data1); System.out.println("data1 = " + Arrays.toString(data1)); // data1=[4,1,2] mystery(data2); System.out.println("data2 = " + Arrays.toString(data2)); // data2=[2,1,2,4] mystery(data3); System.out.println("data3 = " + Arrays.toString(data3)); // data3=[1,1,2,1,6] System.out.println(); 108 [5, 10, 14] 20 8 [5, 10, 14] [3, 4, 5] [1,2] // 자바는 pass-by-value 방식이라서, 내부에서는바뀌지만 [1, 2] [3, 4, 5] // 자바는 pass-by-value 방식이라서, 외부에는영향을주지않는다. data1 = [4, 1, 2] data2 = [2, 1, 2, 4] data3 = [1, 1, 2, 1, 6] 2/9

3 3. 다음은클래스상속관계에서다형성을보여주고있다. 아래의질문에답하라. (30 점 ) interface I { void method1(int v); public abstract class A implements I { public abstract void method2(); public void method3() { System.out.println(this); return "a"; public class D extends A { public void method1(int v) { System.out.println("d1 " + v); public void method2() { System.out.println("d2"); return "d"; public class C extends A { protected int m = 10; public void method1(int v) { System.out.println("c1 " + v); public void method2() { System.out.println("c2 " + m); return "c"; public class B extends C { protected int m = 20; public void method2() { System.out.println("b2 " + this.m + " " + super.m); // (3.3) return "b"; public class E extends C { public void method2() { System.out.println("e2 " + this.m + " " + super.m); // (3.3) 3.1 interface 와 abstract class 가무엇인지간단히설명하라. (5 점 ) 인터페이스는클래스에서구현해야하는동작을지정하는데사용하는추상형. 자바에서인터페이스는다중상속이가능하다. 추상클래스는여러기존의클래스에서공통된부분을추상화한것. 추상클래스를상속하는클래스에게그구현을강제화하는클래스. 하나이상의추상메소드를포함하는클래스이다. 3/9

4 3.2 abstract method 가무엇인지간단히설명하라. 위의코드에서예를찾아서보여라. (5 점 ) 추상메소드는메소드만선언해놓고구현내용은없는것으로, 추상메소드를상속받은클래스는반드시추상메소드를 override 해서구현해야한다. 위의코드에서는 method1 과 method2 가추상메소드이다. 3.3 클래스 B 와 E 의 method2() 에 this.m 과 super.m 의값을말하고자세히설명하라. (5 점 ) 클래스 B 의 method2() 에서사용되는 this.m 은클래스 B 에서다시정의한멤버 m 으로 20, super.m 은클래스 C 의멤버 m 으로 10 이다. 따라서 b 클래스 E 의 method2() 에서사용되는 this.m 과 super.m 은클래스 C 의멤버 m 이므로모두 10 이다. 따라서 e 다음코드의실행결과를적고, 코드에 upcasting 과 downcasting 을표시하라. (5 점 ) A a = new B(); // upcasting System.out.println(a); // dynamic binding A.toString() => B.toString() b B b = new B(); Object o = b; // upcasting ((B)o).method2(); // downcasting B.method2() b System.out.println((B)o); // downcasting, B.toString() b System.out.println((C)o); // downcasting, C.toString() => B.toString() b System.out.println(o); // Object.toString() => B.toString() b System.out.println(); b // B.toString() b // B.method2() b // B.toString() b // C.toString() => B.toString() b // Object.toString() => B.toString() 3.5 다음코드의실행결과를적고이유를자세히설명하라 (dynamic binding 에주의 ). (10 점 ) A[] elements = {new C(), new D(), new E(); for (int i = 0; i < elements.length; i++) { System.out.println(elements[i]); elements[i].method1(i); elements[i].method2(); elements[i].method3(); c // A.toString() => C.toString() c1 0 // A.method1(0) => C.method1(0) c2 10 // A.method2() => C.method2() c // A.method3() 호출하는데그내부의 this 는 c d // A.toString() => D.toString() d1 1 // A.method1(1) => D.method1(1) d2 // A.method2() => D.method2() d // A.method3() 호출하는데그내부의 this 는 d c // A.toString() => E.toString() 없으므로 C.toString() 호출 c1 2 // A.method1(2) => E.method1(2) 없으므로 C.method1(2) 호출 e // A.method2() => E.method2() c // A.method3() 호출하는데그내부의 this 는 e, 하지만 E.toString() 이없으므로 C.toString() 호출 4/9

5 4. 다음은 Value 와 TripleValue 클래스이다. Collection 관련질문에답하라. (30 점 ) import java.util.*; public class Value implements Comparable<Value> { private int x; private int y; public Value() { this(0, 0); public Value(int x, int y) { set(x, y); public void set(int x, int y) { this.x = x; this.y = y; public int getx() { return x; public int gety() { return y; return x + "," + y; public boolean equals(object other) { if (this == other) return true; if (other instanceof Value) { Value that = (Value) other; return x == that.x && y == that.y; return false; public int hashcode() { return Objects.hash(x, y); public int compareto(value other) { return x other.x; public static Comparator<Value> YComparator = new Comparator<Value>() { public int compare(value v1, Value v2) { return v1.y v2.y; ; import java.util.*; public class TripleValue extends Value { private int z; public TripleValue() { this(0, 0, 0); public TripleValue(int x, int y, int z) { super(x, y); this.z = z; public void set(int x, int y, int z) { super.set(x, y); 5/9

6 this.z = z; public int getz() { return z; return getx() + "," + gety() + "," + z; public boolean equals(object other) { if (this == other) return true; if (other instanceof TripleValue) { TripleValue that = (TripleValue)other; return getx() == that.getx() && gety() == that.gety() && z == that.z; return false; public int hashcode() { return Objects.hash(getX(), gety(), z); public static Comparator<TripleValue> ZComparator = new Comparator<TripleValue>() { public int compare(triplevalue v1, TripleValue v2) { return v1.z v2.z; ; 4.1 다음코드의실행결과와같도록, values 를사용하여 List<Value> list 를작성하라. (5 점 ) Value[] values = { new Value(1, 2), new Value(1, 2), new TripleValue( 3, 4, 5), new TripleValue( 3, 4, 5), new TripleValue(7, 8, 9) ; for (Value value : values) System.out.println(value); List<Value> list = new ArrayList<Value>(); for (Value value : values) { list.add(value); for (Value value : list) { System.out.println(value); 4.2 위 4.1 의 list 를사용하여, 각각 X, Y 값으로 sort 하는코드를작성하라. (5 점 ) list.sort(null); // 기본 X 값으로 sort. Comparable<Value> 의 compareto 를사용 list.sort(value.ycomparator); // Y 값으로 sort 는 Comparator<Value> 의 compare 사용 // 만약 list 의 element 가 TripleValue 였다면 list.sort(triplevalue.zcomparator) 사용가능 // 또는 Collections.sort(list); // 기본 X 값으로 sort. Comparable<Value> 의 compareto 를사용 Collections.sort(list, Value.YComparator); // Y 값으로 sort 는 Comparator<Value> 의 compare 사용 6/9

7 4.3 위 4.1 의 values 를사용한 HashMap 코드이다. 다음실행결과를적어라. (5 점 ) Map<Value, Integer> map = new HashMap<Value, Integer>(); for (int i = 0; i < values.length; i++) { map.put(values[i], i+1); for (Map.Entry<Value, Integer> e : map.entryset()) { System.out.println(e.getKey() + " => " + e.getvalue()); map.remove(values[2]); for (Map.Entry<Value, Integer> e : map.entryset()) { System.out.println(e.getKey() + " => " + e.getvalue()); 1, 2 => 2 7, 8, 9 => 5 3, 4, 5 => 4 // remove 후 1, 2 => 2 7, 8, 9 => 위의 4.3 실행결과와같도록, foreach 대신 iterator 와 while 를사용하여동일한코드를작성하라. (5 점 ) Iterator<Value> it = map.keyset().iterator(); while (it.hasnext()) { Value key = it.next(); Integer value = map.get(key); System.out.println(key + " => " + value); 4.5 다음코드의실행결과를적고 == 과 equals 와 hashcode 를자세히설명하라. (10 점 ) TripleValue v1 = new TripleValue(1,2,3); TripleValue v2 = new TripleValue(1,2,3); TripleValue v3 = v1; System.out.println("v1=" + v1); System.out.println("v2=" + v2); System.out.println("v3=" + v3); System.out.println("v1 == v2 " + (v1 == v2)); System.out.println("v1 == v3 " + (v1 == v3)); System.out.println("v1 equals v2 " + v1.equals(v2)); System.out.println("v1 equals v3 " + v1.equals(v3)); System.out.println("v1.hashCode == v2.hashcode " + (v1.hashcode() == v2.hashcode())); System.out.println("v1.hashCode == v3.hashcode " + (v1.hashcode() == v3.hashcode())); v1=1,2,3 v2=1,2,3 v3=1,2,3 v1 == v2 false v1 == v3 true // 레퍼런스가같은 v1 == v3 v1 equals v2 true // 객체의내용이같으므로 (equals 재정의되어있으므로 ) v1 equals v3 true // 객체의내용이같으므로 (equals 재정의되어있으므로 ) v1.hashcode == v2.hashcode true // hashcode 재정의되어있으므로 v1.hashcode == v3.hashcode true // hashcode 재정의되어있으므로 == 연산자는 reference type 의경우, reference 가같은지를비교한다. equals 메소드는두객체의내용이같은지를비교한다. hashcode 메소드는객체의내용으로 hashcode 값을생성한다. 따라서객체의내용이같을경우같은 hashcode 를갖게된다. hashcode 가 override 되어있을경우, HashMap 이나 HashSet 을사용하는 collection 에서동일한 Key 로사용할수없다. 7/9

8 5. 다음은 TripleCalculatorFrame 클래스이다. 아래빈칸에코드를채워라. (20 점 ) // TripleOperator public enum TripleOperator { MIN, MAX, MEDIAN, MEAN, SUM; public static TripleOperator nameof(int value) { switch (value) { case 0: return MIN; case 1: return MAX; case 2: return MEDIAN; case 3: return MEAN; case 4: return SUM; default: return null; public double calculate(int x, int y, int z) { switch (this) { case MIN: return Math.min(Math.min(x, y), z); case MAX: return Math.max(Math.max(x, y), z); case MEDIAN: return Math.max(Math.min(x,y), Math.min(Math.max(x,y),z)); case MEAN: return (x + y + z) / 3.0; case SUM: return x + y + z; default: throw new AssertionError("Unknown operations " + this); // TripleCalculator public class TripleCalculator { private TripleValue value; // x,y,z value private TripleOperator op; // operator public TripleCalculator() { set(0, 0, 0, TripleOperator.MIN); public void set(int x, int y, int z, TripleOperator op) { this.value = new TripleValue(x, y, z); this.op = op; public double getw() { return op.calculate(value.getx(), value.gety(), value.getz()); // TripleCalculatorFrame import java.awt.event.*; import javax.swing.*; public class TripleCalculatorFrame extends JFrame implements ActionListener, KeyListener { JLabel[] labels = new JLabel[4]; JTextField[] textfields = new JTextField[4]; JRadioButton[] rbuttons = new JRadioButton[5]; String[] names = {"MIN", "MAX", "MEDIAN", "MEAN", "SUM"; ButtonGroup rgroup = new ButtonGroup(); JPanel rpanel = new JPanel(); TripleCalculator calc = new TripleCalculator(); public TripleCalculatorFrame() { super("triplecalculatorframe"); this.setlayout(null); for (int i = 0; i < 3; i++) { labels[i] = new JLabel(" 숫자 " + (i+1)); labels[i].setbounds(10, * i, 50, 25); textfields[i] = new JTextField("0", 10); textfields[i].setbounds(100, * i, 200, 25); textfields[i].addkeylistener(this); // event 8/9

9 this.add(labels[i]); this.add(textfields[i]); for (int i = 0; i < 5; i++) { rbuttons[i] = new JRadioButton(names[i]); rbuttons[i].addactionlistener(this); // event rgroup.add(rbuttons[i]); rpanel.add(rbuttons[i]); rbuttons[0].setselected(true); rpanel.setbounds(10, 100, 300, 25); this.add(rpanel); labels[3] = new JLabel(" 결과 "); labels[3].setbounds(10, 150, 50, 25); textfields[3] = new JTextField(10); textfields[3].setbounds(100, 150, 200, 25); this.add(labels[3]); this.add(textfields[3]); setsize(350, 250); setresizable(false); setvisible(true); setdefaultcloseoperation(jframe.exit_on_close); private int selectoperator() { for (int i = 0; i < 5; i++) { if (rbuttons[i].isselected()) { return i; return 0; private void calculate(int index) { int x = Integer.parseInt(textfields[0].getText()); int y = Integer.parseInt(textfields[1].getText()); int z = Integer.parseInt(textfields[2].getText()); TripleOperator op = TripleOperator.nameOf(index); calc.set(x, y, z, op); labels[3].settext(names[index]); textfields[3].settext("" + calc.getw()); public void actionperformed(actionevent e) { JRadioButton rbutton = (JRadioButton) e.getsource(); for (int i = 0; i < 5; i++) { if (rbutton == rbuttons[i]) { calculate(i); // 계산 public void keytyped(keyevent e) { public void keyreleased(keyevent e) { public void keypressed(keyevent e) { int key = e.getkeycode(); if (key == KeyEvent.VK_ENTER) { calculate(selectoperator()); // 계산 - 끝 - 9/9

Microsoft Word - java19-1-final-answer.doc

Microsoft Word - java19-1-final-answer.doc 기말고사 담당교수 : 단국대학교응용컴퓨터공학박경신 답은반드시답안지에기술할것. 공간이부족할경우반드시답안지몇쪽의뒤에있다고명기한후기술할것. 그외의경우의답안지뒤쪽이나연습지에기술한내용은답안으로인정안함. 답에는반드시네모를쳐서확실히표시할것. 답안지에학과, 학번, 이름외에본인의암호 (4자리숫자 ) 를기입하면성적공고시학번대신암호를 사용할것임. 1. 다음코드의실행결과를적어라

More information

Microsoft Word - java19-1-midterm-answer.doc

Microsoft Word - java19-1-midterm-answer.doc 중간고사 담당교수 : 단국대학교응용컴퓨터공학박경신 답은반드시답안지에기술할것. 공간이부족할경우반드시답안지몇쪽의뒤에있다고명기한후기술할것. 그외의경우의답안지뒤쪽이나연습지에기술한내용은답안으로인정안함. 답에는반드시네모를쳐서확실히표시할것. 답안지에학과, 학번, 이름외에본인의암호 (4자리숫자 ) 를기입하면성적공고시학번대신암호를 사용할것임. 1. 다음질문에답을하라. (55

More information

JAVA PROGRAMMING 실습 08.다형성

JAVA PROGRAMMING 실습 08.다형성 2015 학년도 2 학기 1. 추상메소드 선언은되어있으나코드구현되어있지않은메소드 abstract 키워드사용 메소드타입, 이름, 매개변수리스트만선언 public abstract String getname(); public abstract void setname(string s); 2. 추상클래스 abstract 키워드로선언한클래스 종류 추상메소드를포함하는클래스

More information

중간고사

중간고사 기말고사 담당교수 : 단국대학교응용컴퓨터공학박경신 답은반드시답안지에기술할것. 공간이부족할경우반드시답안지몇쪽의뒤에있다고명기한 후기술할것. 그외의경우의답안지뒤쪽이나연습지에기술한내용은답안으로인정안함. 답 에는반드시네모를쳐서확실히표시할것. 답안지에학과, 학번, 이름외에본인의암호 (4 자리숫자 ) 를기입하면성적공고시학번대신암호를 사용할것임. // ArithmeticOperator

More information

gnu-lee-oop-kor-lec10-1-chap10

gnu-lee-oop-kor-lec10-1-chap10 어서와 Java 는처음이지! 제 10 장이벤트처리 이벤트분류 액션이벤트 키이벤트 마우스이동이벤트 어댑터클래스 스윙컴포넌트에의하여지원되는이벤트는크게두가지의카테고리로나누어진다. 사용자가버튼을클릭하는경우 사용자가메뉴항목을선택하는경우 사용자가텍스트필드에서엔터키를누르는경우 두개의버튼을만들어서패널의배경색을변경하는프로그램을작성하여보자. 이벤트리스너는하나만생성한다. class

More information

Microsoft PowerPoint - 04-UDP Programming.ppt

Microsoft PowerPoint - 04-UDP Programming.ppt Chapter 4. UDP Dongwon Jeong djeong@kunsan.ac.kr http://ist.kunsan.ac.kr/ Dept. of Informatics & Statistics 목차 UDP 1 1 UDP 개념 자바 UDP 프로그램작성 클라이언트와서버모두 DatagramSocket 클래스로생성 상호간통신은 DatagramPacket 클래스를이용하여

More information

Microsoft PowerPoint - 14주차 강의자료

Microsoft PowerPoint - 14주차 강의자료 Java 로만드는 Monster 잡기게임예제이해 2014. 12. 2 게임화면및게임방법 기사초기위치 : (0,0) 아이템 10 개랜덤생성 몬스터 10 놈랜덤생성 Frame 하단에기사위치와기사파워출력방향키로기사이동아이템과몬스터는고정종료버튼클릭하면종료 Project 구성 GameMain.java GUI 환경설정, Main Method 게임객체램덤위치에생성 Event

More information

q 이장에서다룰내용 1 객체지향프로그래밍의이해 2 객체지향언어 : 자바 2

q 이장에서다룰내용 1 객체지향프로그래밍의이해 2 객체지향언어 : 자바 2 객체지향프로그래밍 IT CookBook, 자바로배우는쉬운자료구조 q 이장에서다룰내용 1 객체지향프로그래밍의이해 2 객체지향언어 : 자바 2 q 객체지향프로그래밍의이해 v 프로그래밍기법의발달 A 군의사업발전 1 단계 구조적프로그래밍방식 3 q 객체지향프로그래밍의이해 A 군의사업발전 2 단계 객체지향프로그래밍방식 4 q 객체지향프로그래밍의이해 v 객체란무엇인가

More information

5장.key

5장.key JAVA Programming 1 (inheritance) 2!,!! 4 3 4!!!! 5 public class Person {... public class Student extends Person { // Person Student... public class StudentWorker extends Student { // Student StudentWorker...!

More information

07 자바의 다양한 클래스.key

07 자바의 다양한 클래스.key [ 07 ] . java.lang Object, Math, String, StringBuffer Byte, Short, Integer, Long, Float, Double, Boolean, Character. java.util Random, StringTokenizer Calendar, GregorianCalendar, Date. Collection, List,

More information

09-interface.key

09-interface.key 9 Database insert(record r): boolean find(key k): Record 1 Record getkey(): Key * Record Key Database.? Key equals(key y): boolean Database insert(record r): boolean find(key k): Record * Database OK 1

More information

<4D F736F F F696E74202D20C1A63138C0E520C0CCBAA5C6AE20C3B3B8AE28B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63138C0E520C0CCBAA5C6AE20C3B3B8AE28B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 18 장이벤트처리 이번장에서학습할내용 이벤트처리의개요 이벤트 액션이벤트 Key, Mouse, MouseMotion 어댑터클래스 버튼을누르면반응하도록만들어봅시다. 이번장의목표 버튼을누르면버튼의텍스트가변경되게한다. 이벤트처리과정 이벤트처리과정 (1) 이벤트를발생하는컴포넌트를생성하여야한다. 이벤트처리과정 (2) 이벤트리스너클래스를작성한다.

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 인터페이스, 람다식, 패키지 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 홈네트워킹 public interface RemoteControl { public void turnon(); // 가전제품을켠다. public void turnoff(); // 가전제품을끈다. 인터페이스를구현 public class Television

More information

10장.key

10장.key JAVA Programming 1 2 (Event Driven Programming)! :,,,! ( )! : (batch programming)!! ( : )!!!! 3 (Mouse Event, Action Event) (Mouse Event, Action Event) (Mouse Event, Container Event) (Key Event) (Key Event,

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 2... ( ). ( ). @ vs. logic data method variable behavior attribute method field Flow (Type), ( ) member @ () : C program Method A ( ) Method B ( ) Method C () program : Java, C++, C# data @ Program

More information

Design Issues

Design Issues 11 COMPUTER PROGRAMMING INHERIATANCE CONTENTS OVERVIEW OF INHERITANCE INHERITANCE OF MEMBER VARIABLE RESERVED WORD SUPER METHOD INHERITANCE and OVERRIDING INHERITANCE and CONSTRUCTOR 2 Overview of Inheritance

More information

PowerPoint Presentation

PowerPoint Presentation Class - Property Jo, Heeseung 목차 section 1 클래스의일반구조 section 2 클래스선언 section 3 객체의생성 section 4 멤버변수 4-1 객체변수 4-2 클래스변수 4-3 종단 (final) 변수 4-4 멤버변수접근방법 section 5 멤버변수접근한정자 5-1 public 5-2 private 5-3 한정자없음

More information

11장.key

11장.key JAVA Programming 1 GUI 2 2 1. GUI! GUI! GUI.! GUI! GUI 2. GUI!,,,!! GUI! GUI 11 : GUI 12 : GUI 3 4, JComponent 11-1 :, JComponent 5 import java.awt.*; import java.awt.event.*; import javax.swing.*; public

More information

Microsoft PowerPoint - 2강

Microsoft PowerPoint - 2강 컴퓨터과학과 김희천교수 학습개요 Java 언어문법의기본사항, 자료형, 변수와상수선언및사용법, 각종연산자사용법, if/switch 등과같은제어문사용법등에대해설명한다. 또한 C++ 언어와선언 / 사용방법이다른 Java의배열선언및사용법에대해서설명한다. Java 언어의효과적인활용을위해서는기본문법을이해하는것이중요하다. 객체지향의기본개념에대해알아보고 Java에서어떻게객체지향적요소를적용하고있는지살펴본다.

More information

PowerPoint Presentation

PowerPoint Presentation Package Class 1 Heeseung Jo 목차 section 1 패키지개요와패키지의사용 section 2 java.lang 패키지의개요 section 3 Object 클래스 section 4 포장 (Wrapper) 클래스 section 5 문자열의개요 section 6 String 클래스 section 7 StringBuffer 클래스 section

More information

05-class.key

05-class.key 5 : 2 (method) (public) (private) (interface) 5.1 (Method), (public method) (private method) (constructor), 3 4 5.2 (client). (receiver)., System.out.println("Hello"); (client object) (receiver object)

More information

Microsoft PowerPoint - Java7.pptx

Microsoft PowerPoint - Java7.pptx HPC & OT Lab. 1 HPC & OT Lab. 2 실습 7 주차 Jin-Ho, Jang M.S. Hanyang Univ. HPC&OT Lab. jinhoyo@nate.com HPC & OT Lab. 3 Component Structure 객체 (object) 생성개념을이해한다. 외부클래스에대한접근방법을이해한다. 접근제어자 (public & private)

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 클래스, 객체, 메소드 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 필드만있는클래스 텔레비젼 2 예제 1. 필드만있는클래스 3 예제 2. 여러개의객체생성하기 4 5 예제 3. 메소드가추가된클래스 public class Television { int channel; // 채널번호 int volume; // 볼륨 boolean

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 Power Java 제 11 장상속 이번장에서학습할내용 상속이란? 상속의사용 메소드재정의 접근지정자 상속과생성자 Object 클래스 종단클래스 상속을코드를재사용하기위한중요한기법입니다. 상속이란? 상속의개념은현실세계에도존재한다. 상속의장점 상속의장점 상속을통하여기존클래스의필드와메소드를재사용 기존클래스의일부변경도가능 상속을이용하게되면복잡한 GUI 프로그램을순식간에작성

More information

중간고사

중간고사 중간고사 담당교수 : 단국대학교응용컴퓨터공학박경신 답은반드시답안지에기술할것. 공간이부족할경우반드시답안지몇쪽의뒤에있다고명기한후기술할것. 그외의경우의답안지뒤쪽이나연습지에기술한내용은답안으로인정안함. 답에는반드시네모를쳐서확실히표시할것. 답안지에학과, 학번, 이름외에본인의암호 (4자리숫자 ) 를기입하면성적공고시학번대신암호를사용할것임. 1. JSP 란무엇인가? 간단히설명하라.

More information

<4D F736F F F696E74202D20C1A63230C0E520BDBAC0AE20C4C4C6F7B3CDC6AE203128B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63230C0E520BDBAC0AE20C4C4C6F7B3CDC6AE203128B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 20 장스윙컴포넌트 1 이번장에서학습할내용 텍스트컴포넌트 텍스트필드 텍스트영역 스크롤페인 체크박스 라디오버튼 스윙에서제공하는기초적인컴포넌트들을살펴봅시다. 스윙텍스트컴포넌트들 종류텍스트컴포넌트그림 텍스트필드 JTextField JPasswordField JFormattedTextField 일반텍스트영역 JTextArea 스타일텍스트영역

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 그래픽사용자인터페이스 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 프레임생성 (1) import javax.swing.*; public class FrameTest { public static void main(string[] args) { JFrame f = new JFrame("Frame Test"); JFrame

More information

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx 2018 학년도 1 학기 JAVA 프로그래밍 II 514760-1 2018 년봄학기 5/10/2018 박경신 Lab#1 (ImageTest) Lab#1 은영상파일 (Image) 을읽어서정보를출력 Java Tutorials Lesson: Working with Images https://docs.oracle.com/javase/tutorial/2d/images/index.html

More information

PowerPoint Presentation

PowerPoint Presentation public class SumTest { public static void main(string a1[]) { int a, b, sum; a = Integer.parseInt(a1[0]); b = Integer.parseInt(a1[1]); sum = a + b ; // 두수를더하는부분입니다 System.out.println(" 두수의합은 " + sum +

More information

JAVA PROGRAMMING 실습 09. 예외처리

JAVA PROGRAMMING 실습 09. 예외처리 2015 학년도 2 학기 예외? 프로그램실행중에발생하는예기치않은사건 예외가발생하는경우 정수를 0으로나누는경우 배열의크기보다큰인덱스로배열의원소를접근하는경우 파일의마지막부분에서데이터를읽으려고하는경우 예외처리 프로그램에문제를발생시키지않고프로그램을실행할수있게적절한조치를취하는것 자바는예외처리기를이용하여예외처리를할수있는기법제공 자바는예외를객체로취급!! 나뉨수를입력하시오

More information

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 (   ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각 JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( http://java.sun.com/javase/6/docs/api ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각선의길이를계산하는메소드들을작성하라. 직사각형의가로와세로의길이는주어진다. 대각선의길이는 Math클래스의적절한메소드를이용하여구하라.

More information

ilist.add(new Integer(1))과 같이 사용하지 않고 ilist.add(1)과 같이 사용한 것은 자바 5.0에 추가된 기본 자료형과 해당 객체 자료 형과의 오토박싱/언박싱 기능을 사용한 것으로 오토박싱이란 자바 컴파일러가 객체를 요구하는 곳에 기본 자료형

ilist.add(new Integer(1))과 같이 사용하지 않고 ilist.add(1)과 같이 사용한 것은 자바 5.0에 추가된 기본 자료형과 해당 객체 자료 형과의 오토박싱/언박싱 기능을 사용한 것으로 오토박싱이란 자바 컴파일러가 객체를 요구하는 곳에 기본 자료형 바에 제네릭스(generics)를 도입하기 위한 연구는 이미 8년 전인 1996년부터라고 한다. 실제로 자바에 제네릭스를 도입하 는 몇 가지 방안들이 논문으로 나오기 시작한 것이 1998년 초임을 감 안하면 무려 8년이 지난 후에야 자바 5.0에 전격 채택되었다는 것은 이것이 얼마나 어려운 일이었나 하는 것을 보여준다. 자바의 스펙을 결정하는 표준화 절차인

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 인터페이스 배효철 th1g@nate.com 1 목차 인터페이스의역할 인터페이스선언 인터페이스구현 인터페이스사용 타입변환과다형성 인터페이스상속 디폴트메소드와인터페이스확장 2 인터페이스의역할 인터페이스란? 개발코드와객체가서로통신하는접점 개발코드는인터페이스의메소드만알고있으면 OK 인터페이스의역할 개발코드가객체에종속되지않게 -> 객체교체할수있도록하는역할 개발코드변경없이리턴값또는실행내용이다양해질수있음

More information

gnu-lee-oop-kor-lec06-3-chap7

gnu-lee-oop-kor-lec06-3-chap7 어서와 Java 는처음이지! 제 7 장상속 Super 키워드 상속과생성자 상속과다형성 서브클래스의객체가생성될때, 서브클래스의생성자만호출될까? 아니면수퍼클래스의생성자도호출되는가? class Base{ public Base(String msg) { System.out.println("Base() 생성자 "); ; class Derived extends Base

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 3 if, if else, if else if, switch case for, while, do while break, continue : System.in, args, JOptionPane for (,, ) @ vs. logic data method variable Data Data Flow (Type), ( ) @ Member field

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Lab 4 ADT Design 클래스로정의됨. 모든객체들은힙영역에할당됨. 캡슐화 (Encapsulation) : Data representation + Operation 정보은닉 (Information Hiding) : Opertion부분은가려져있고, 사용자가 operation으로만사용가능해야함. 클래스정의의형태 public class Person { private

More information

Microsoft Word - cg07-midterm.doc

Microsoft Word - cg07-midterm.doc 중간고사 담당교수 : 단국대학교멀티미디어공학전공박경신 답은반드시답안지에기술할것. 공간이부족할경우반드시답안지몇쪽의뒤에있다고명기한후기술할것. 그외의경우의답안지뒤쪽이나연습지에기술한내용은답안으로인정안함. 답에는반드시네모를쳐서확실히표시할것. 답안지에학과, 학번, 이름외에본인의암호를기입하면성적공고시학번대신암호를사용할것임. 1. 맞으면 true, 틀리면 false를적으시오.

More information

<4D F736F F F696E74202D20C1A63233C0E520B1D7B7A1C7C820C7C1B7CEB1D7B7A1B9D628B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63233C0E520B1D7B7A1C7C820C7C1B7CEB1D7B7A1B9D628B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 23 장그래픽프로그래밍 이번장에서학습할내용 자바에서의그래픽 기초사항 기초도형그리기 색상 폰트 Java 2D Java 2D를이용한그리기 Java 2D 를이용한채우기 도형회전과평행이동 자바를이용하여서화면에그림을그려봅시다. 자바그래픽데모 자바그래픽의두가지방법 자바그래픽 AWT Java 2D AWT를사용하면기본적인도형들을쉽게그릴수있다. 어디서나잘실행된다.

More information

슬라이드 1

슬라이드 1 컬렉션프레임워크 (Collection Framework) 의정의 - 다수의데이터를쉽게처리할수있는표준화된방법을제공하는클래스들 - 데이터의집합을다루고표현하기위한단일화된구조 (architecture) - JDK 1.2 이전까지는 Vector, Hashtable, Properties와같은컬렉션클래스로서로다른각자의방식으로처리 - 컬렉션프레임워크는다수의데이터를다루는데필요한다양하고풍부한클래스들을제공하므로프로그래머의부담을상당부분덜어준다.

More information

<4D F736F F F696E74202D20C1A63139C0E520B9E8C4A120B0FCB8AEC0DA28B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63139C0E520B9E8C4A120B0FCB8AEC0DA28B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 19 장배치관리자 이번장에서학습할내용 배치관리자의개요 배치관리자의사용 FlowLayout BorderLayout GridLayout BoxLayout CardLayout 절대위치로배치 컨테이너안에서컴포넌트를배치하는방법에대하여살펴봅시다. 배치관리자 (layout manager) 컨테이너안의각컴포넌트의위치와크기를결정하는작업 [3/70] 상당히다르게보인다.

More information

gnu-lee-oop-kor-lec11-1-chap15

gnu-lee-oop-kor-lec11-1-chap15 어서와 Java 는처음이지! 제 15 장컬렉션 컬렉션 (collection) 은자바에서자료구조를구현한클래스 자료구조로는리스트 (list), 스택 (stack), 큐 (queue), 집합 (set), 해쉬테이블 (hash table) 등이있다. 자바는컬렉션인터페이스와컬렉션클래스로나누어서제공한다. 자바에서는컬렉션인터페이스를구현한클래스도함께제공하므로이것을간단하게사용할수도있고아니면각자필요에맞추어인터페이스를자신의클래스로구현할수도있다.

More information

PowerPoint Presentation

PowerPoint Presentation Package Class 3 Heeseung Jo 목차 section 1 패키지개요와패키지의사용 section 2 java.lang 패키지의개요 section 3 Object 클래스 section 4 포장 (Wrapper) 클래스 section 5 문자열의개요 section 6 String 클래스 section 7 StringBuffer 클래스 section

More information

제11장 프로세스와 쓰레드

제11장 프로세스와 쓰레드 제9장자바쓰레드 9.1 Thread 기초 (1/5) 프로그램 명령어들의연속 (a sequence of instruction) 프로세스 / Thread 실행중인프로그램 (program in execution) 프로세스생성과실행을위한함수들 자바 Thread 2 9.1 Thread 기초 (2/5) 프로세스단위작업의문제점 프로세스생성시오버헤드 컨텍스트스위치오버헤드

More information

JUNIT 실습및발표

JUNIT 실습및발표 JUNIT 실습및발표 JUNIT 접속 www.junit.org DownLoad JUnit JavaDoc API Document 를참조 JUNIT 4.8.1 다운로드 설치파일 (jar 파일 ) 을다운로드 CLASSPATH 를설정 환경변수에서설정 실행할클래스에서 import JUnit 설치하기 테스트실행주석 @Test Test 를실행할 method 앞에붙임 expected

More information

제8장 자바 GUI 프로그래밍 II

제8장 자바 GUI 프로그래밍 II 제8장 MVC Model 8.1 MVC 모델 (1/7) MVC (Model, View, Controller) 모델 스윙은 MVC 모델에기초를두고있다. MVC란 Xerox의연구소에서 Smalltalk 언어를바탕으로사용자인터페이스를개발하기위한방법 MVC는 3개의구성요소로구성 Model : 응용프로그램의자료를표현하기위한모델 View : 자료를시각적으로 (GUI 방식으로

More information

Spring Boot/JDBC JdbcTemplate/CRUD 예제

Spring Boot/JDBC JdbcTemplate/CRUD 예제 Spring Boot/JDBC JdbcTemplate/CRUD 예제 오라클자바커뮤니티 (ojc.asia, ojcedu.com) Spring Boot, Gradle 과오픈소스인 MariaDB 를이용해서 EMP 테이블을만들고 JdbcTemplate, SimpleJdbcTemplate 을이용하여 CRUD 기능을구현해보자. 마리아 DB 설치는다음 URL 에서확인하자.

More information

ch09

ch09 9 Chapter CHAPTER GOALS B I G J A V A 436 CHAPTER CONTENTS 9.1 436 Syntax 9.1 441 Syntax 9.2 442 Common Error 9.1 442 9.2 443 Syntax 9.3 445 Advanced Topic 9.1 445 9.3 446 9.4 448 Syntax 9.4 454 Advanced

More information

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D> Power Java 제 8 장클래스와객체 I 이번장에서학습할내용 클래스와객체 객체의일생직접 메소드클래스를 필드작성해 UML 봅시다. QUIZ 1. 객체는 속성과 동작을가지고있다. 2. 자동차가객체라면클래스는 설계도이다. 먼저앞장에서학습한클래스와객체의개념을복습해봅시다. 클래스의구성 클래스 (class) 는객체의설계도라할수있다. 클래스는필드와메소드로이루어진다.

More information

A Tour of Java IV

A Tour of Java IV A Tour of Java IV Sungjoo Ha March 25th, 2016 Sungjoo Ha 1 / 35 Review First principle 문제가생기면침착하게영어로구글에서찾아본다. 타입은가능한값의집합과연산의집합을정의한다. 기본형이아니라면이름표가메모리에달라붙는다. 클래스로사용자정의타입을만든다. 프로그래밍은복잡도관리가중요하다. OOP 는객체가서로메시지를주고받는방식으로프로그램을구성해서복잡도관리를꾀한다.

More information

PowerPoint Presentation

PowerPoint Presentation 자바프로그래밍 1 클래스와메소드심층연구 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 접근제어 class A { private int a; int b; public int c; // 전용 // 디폴트 // 공용 public class Test { public static void main(string args[]) { A obj = new

More information

PowerPoint Presentation

PowerPoint Presentation public class SumTest { public static void main(string a1[]) { int a, b, sum; a = Integer.parseInt(a1[0]); b = Integer.parseInt(a1[1]); sum = a + b ; // 두수를더하는부분입니다 System.out.println(" 두수의합은 " + sum +

More information

예제 2) Test.java class A intvar= 10; void method() class B extends A intvar= 20; 1"); void method() 2"); void method1() public class Test 3"); args) A

예제 2) Test.java class A intvar= 10; void method() class B extends A intvar= 20; 1); void method() 2); void method1() public class Test 3); args) A 제 10 장상속 예제 1) ConstructorTest.java class Parent public Parent() super - default"); public Parent(int i) this("hello"); super(int) constructor" + i); public Parent(char c) this(); super(char) constructor

More information

JAVA PROGRAMMING 실습 05. 객체의 활용

JAVA PROGRAMMING 실습 05. 객체의 활용 public class Person{ public String name; public int age; } public Person(){ } public Person(String s, int a){ name = s; age = a; } public String getname(){ return name; } @ 객체의선언 public static void main(string

More information

9장.key

9장.key JAVA Programming 1 GUI(Graphical User Interface) 2 GUI!,! GUI! GUI, GUI GUI! GUI AWT Swing AWT - java.awt Swing - javax.swing AWT Swing 3 AWT(Abstract Windowing Toolkit)! GUI! java.awt! AWT (Heavy weight

More information

단국대학교멀티미디어공학그래픽스프로그래밍중간고사 (2011 년봄학기 ) 2011 년 4 월 26 일학과학번이름 중간고사 담당교수 : 단국대학교멀티미디어공학전공박경신 l 답은반드시답안지에기술할것. 공간이부족할경우반드시답안지몇쪽의뒤에있다고명기한후기술할것. 그외의경우의답안지뒤

단국대학교멀티미디어공학그래픽스프로그래밍중간고사 (2011 년봄학기 ) 2011 년 4 월 26 일학과학번이름 중간고사 담당교수 : 단국대학교멀티미디어공학전공박경신 l 답은반드시답안지에기술할것. 공간이부족할경우반드시답안지몇쪽의뒤에있다고명기한후기술할것. 그외의경우의답안지뒤 중간고사 담당교수 : 단국대학교멀티미디어공학전공박경신 l 답은반드시답안지에기술할것. 공간이부족할경우반드시답안지몇쪽의뒤에있다고명기한후기술할것. 그외의경우의답안지뒤쪽이나연습지에기술한내용은답안으로인정안함. 답에는반드시네모를쳐서확실히표시할것. l 답안지에학과, 학번, 이름외에본인의암호를기입하면성적공고시학번대신암호를사용할것임. 1. 맞으면 true, 틀리면 false를적으시오.

More information

자바GUI실전프로그래밍2_장대원.PDF

자바GUI실전프로그래밍2_장대원.PDF JAVA GUI - 2 JSTORM http://wwwjstormpekr JAVA GUI - 2 Issued by: < > Document Information Document title: JAVA GUI - 2 Document file name: Revision number: Issued by: Issue Date:

More information

02 C h a p t e r Java

02 C h a p t e r Java 02 C h a p t e r Java Bioinformatics in J a va,, 2 1,,,, C++, Python, (Java),,, (http://wwwbiojavaorg),, 13, 3D GUI,,, (Java programming language) (Sun Microsystems) 1995 1990 (green project) TV 22 CHAPTER

More information

강의자료

강의자료 Copyright, 2014 MMLab, Dept. of ECE, UOS Java Swing 2014 년 3 월 최성종서울시립대학교전자전기컴퓨터공학부 chois@uos.ac.kr http://www.mmlab.net 차례 2014년 3월 Java Swing 2 2017-06-02 Seong Jong Choi Java Basic Concepts-3 Graphical

More information

C# Programming Guide - Types

C# Programming Guide - Types C# Programming Guide - Types 최도경 lifeisforu@wemade.com 이문서는 MSDN 의 Types 를요약하고보충한것입니다. http://msdn.microsoft.com/enus/library/ms173104(v=vs.100).aspx Types, Variables, and Values C# 은 type 에민감한언어이다. 모든

More information

10.0pt1height.7depth.3width±â10.0pt1height.7depth.3widthÃÊ10.0pt1height.7depth.3widthÅë10.0pt1height.7depth.3width°è10.0pt1height.7depth.3widthÇÁ10.0pt1height.7depth.3width·Î10.0pt1height.7depth.3width±×10.0pt1height.7depth.3width·¡10.0pt1height.7depth.3width¹Ö pt1height.7depth.3widthŬ10.0pt1height.7depth.3width·¡10.0pt1height.7depth.3width½º, 10.0pt1height.7depth.3width°´10.0pt1height.7depth.3widthü, 10.0pt1height.7depth.3widthº¯10.0pt1height.7depth.3width¼ö, 10.0pt1height.7depth.3width¸Þ10.0pt1height.7depth.3width¼Ò10.0pt1height.7depth.3widthµå

10.0pt1height.7depth.3width±â10.0pt1height.7depth.3widthÃÊ10.0pt1height.7depth.3widthÅë10.0pt1height.7depth.3width°è10.0pt1height.7depth.3widthÇÁ10.0pt1height.7depth.3width·Î10.0pt1height.7depth.3width±×10.0pt1height.7depth.3width·¡10.0pt1height.7depth.3width¹Ö pt1height.7depth.3widthŬ10.0pt1height.7depth.3width·¡10.0pt1height.7depth.3width½º, 10.0pt1height.7depth.3width°´10.0pt1height.7depth.3widthü, 10.0pt1height.7depth.3widthº¯10.0pt1height.7depth.3width¼ö, 10.0pt1height.7depth.3width¸Þ10.0pt1height.7depth.3width¼Ò10.0pt1height.7depth.3widthµå 기초통계프로그래밍 클래스, 객체, 변수, 메소드 hmkang@hallym.ac.kr 금융정보통계학과 강희모 ( 금융정보통계학과 ) 기초통계프로그래밍 1 / 26 자바구성파일 소스파일 소스파일 : 사용자가직접에디터에입력하는파일로자바프로그램언어가제공하는형식으로제작 소스파일의확장자는.java 임 컴파일 : javac 명령어를이용하여프로그래머가만든소스파일을컴파일하여실행파일.class

More information

JAVA PROGRAMMING 실습 02. 표준 입출력

JAVA PROGRAMMING 실습 02. 표준 입출력 # 왜생겼나요..? : 절차지향언어가가진단점을보완하고다음의목적을달성하기위해..! 1. 소프트웨어생산성향상 객체지향소프트웨어를새로만드는경우이미만든개체지향소프트웨어를상속받거나객체를 가져다재사용할수있어부분수정을통해소프트웨어를다시만드는부담줄임. 2. 실세계에대한쉬운모델링 실세계의일은절차나과정보다는일과관련된많은물체들의상호작용으로묘사. 캡슐화 메소드와데이터를클래스내에선언하고구현

More information

Cluster management software

Cluster management software 자바네트워크프로그래밍 (OCJP 국제공인자격취득중심 ) 충북대학교 최민 기본예제 예외클래스를정의하고사용하는예제 class NewException extends Exception { public class ExceptionTest { static void methoda() throws NewException { System.out.println("NewException

More information

12-file.key

12-file.key 11 (String).. java.lang.stringbuffer. s String s = "abcd"; s = s + "e"; a b c d e a b c d e ,., "910359,, " "910359" " " " " (token) (token),, (delimiter). java.util.stringtokenizer String s = "910359,,

More information

Microsoft PowerPoint 자바-기본문법(Ch2).pptx

Microsoft PowerPoint 자바-기본문법(Ch2).pptx 자바기본문법 1. 기본사항 2. 자료형 3. 변수와상수 4. 연산자 1 주석 (Comments) 이해를돕기위한설명문 종류 // /* */ /** */ 활용예 javadoc HelloApplication.java 2 주석 (Comments) /* File name: HelloApplication.java Created by: Jung Created on: March

More information

TEST BANK & SOLUTION

TEST BANK & SOLUTION TEST BANK & SOLUTION 어서와자바는처음이지!" 를강의교재로채택해주셔서감사드립니다. 본문제집을만드는데나름대로노력을기울였으나제가가진지식의한계로말미암아잘못된부분이있을것으로사료됩니다. 잘못된부분을발견하시면 chunik@sch.ac.kr로연락주시면더좋은책을만드는데소중하게사용하겠습니다. 다시한번감사드립니다. 1. 자바언어에서지원되는 8 가지의기초자료형은무엇인가?

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 Power Java 제 23 장스레드 이번장에서학습할내용 스레드의개요 스레드의생성과실행 스레드상태 스레드의스케줄링 스레드간의조정 스레드는동시에여러개의프로그램을실행하는효과를냅니다. 멀티태스킹 멀티태스킹 (muli-tasking) 는여러개의애플리케이션을동시에실행하여서컴퓨터시스템의성능을높이기위한기법 스레드란? 다중스레딩 (multi-threading) 은하나의프로그램이동시에여러가지작업을할수있도록하는것

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 명품 JAVA Essential 1 2 학습목표 1. 객체지향상속과자바상속개념이해 2. 클래스상속작성및객체생성 3. protected 접근지정 4. 상속시생성자의실행과정 5. 업캐스팅과 instanceof 연산자 6. 메소드오버라이딩과동적바인딩의이해및활용 7. 추상클래스 8. 인터페이스 상속 (inheritance) 3 객체지향상속 자식이부모유전자를물려받는것과유사한개념

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 상속 배효철 th1g@nate.com 1 목차 상속개념 클래스상속 부모생성자호출 메소드재정의 final 클래스와 final 메소드 protected 접근제한자 타입변환과다형성 추상클래스 2 상속개념 상속 (Inheritance) 이란? 현실세계 : 부모가자식에게물려주는행위 부모가자식을선택해서물려줌 객체지향프로그램 : 자식 ( 하위, 파생 ) 클래스가부모 (

More information

자바 프로그래밍

자바 프로그래밍 5 (kkman@mail.sangji.ac.kr) (Class), (template) (Object) public, final, abstract [modifier] class ClassName { // // (, ) Class Circle { int radius, color ; int x, y ; float getarea() { return 3.14159

More information

Java Programing Environment

Java Programing Environment Lab Exercise #7 Swing Component 프로그래밍 2007 봄학기 고급프로그래밍 김영국충남대전기정보통신공학부 실습내용 실습과제 7-1 : 정규표현식을이용한사용자정보의유효성검사 (ATM 에서사용자등록용도로사용가능 ) 실습과제 7-2 : 숫자맞추기게임 실습과제 7-3 : 은행관리프로그램 고급프로그래밍 Swing Component 프로그래밍 2

More information

JMF3_심빈구.PDF

JMF3_심빈구.PDF JMF JSTORM http://wwwjstormpekr Issued by: < > Revision: Document Information Document title: Document file name: Revision number: Issued by: JMF3_ doc Issue Date:

More information

PowerPoint Presentation

PowerPoint Presentation Class : Method Jo, Heeseung 목차 section 1 생성자 (Constructor) section 2 생성자오버로딩 (Overloading) section 3 예약어 this section 4 메소드 4-1 접근한정자 4-2 클래스메소드 4-3 final, abstract, synchronized 메소드 4-4 메소드반환값 (return

More information

PowerPoint Presentation

PowerPoint Presentation public class SumTest { public static void main(string a1[]) { int a, b, sum; a = Integer.parseInt(a1[0]); b = Integer.parseInt(a1[1]); sum = a + b ; // 두수를더하는부분입니다 System.out.println(" 두수의합은 " + sum +

More information

rmi_박준용_final.PDF

rmi_박준용_final.PDF (RMI) - JSTORM http://wwwjstormpekr (RMI)- Document title: Document file name: Revision number: Issued by: Document Information (RMI)- rmi finaldoc Issue Date: Status:

More information

교육자료

교육자료 THE SYS4U DODUMENT Java Reflection & Introspection 2012.08.21 김진아사원 2012 SYS4U I&C All rights reserved. 목차 I. 개념 1. Reflection 이란? 2. Introspection 이란? 3. Reflection 과 Introspection 의차이점 II. 실제사용예 1. Instance의생성

More information

(Microsoft PowerPoint - java2-lecture3.ppt [\310\243\310\257 \270\360\265\345])

(Microsoft PowerPoint - java2-lecture3.ppt [\310\243\310\257 \270\360\265\345]) Class Class, Collections 514770-1 2017 년봄학기 3/22/2017 박경신 클래스 (Class) 객체의속성과행위선언 객체의설계도혹은틀 객체 (Object) 클래스의틀로찍어낸실체 메모리공간을갖는구체적인실체 클래스를구체화한객체를인스턴스 (instance) 라고부름 객체와인스턴스는같은뜻으로사용 클래스구조 클래스접근권한, public 다른클래스들에서이클래스를사용하거나접근할수있음을선언

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 상속 손시운 ssw5176@kangwon.ac.kr 상속이란? 상속의개념은현실세계에도존재한다. 2 상속의장점 상속의장점 상속을통하여기존클래스의필드와메소드를재사용 기존클래스의일부변경도가능 상속을이용하게되면복잡한 GUI 프로그램을순식간에작성 상속은이미작성된검증된소프트웨어를재사용 신뢰성있는소프트웨어를손쉽게개발, 유지보수 코드의중복을줄일수있다. 3

More information

03-JAVA Syntax(2).PDF

03-JAVA Syntax(2).PDF JAVA Programming Language Syntax of JAVA (literal) (Variable and data types) (Comments) (Arithmetic) (Comparisons) (Operators) 2 HelloWorld application Helloworldjava // class HelloWorld { //attribute

More information

슬라이드 1

슬라이드 1 12 장. GUI 학습목표 GUI 이벤트, 이벤트리스너와이벤트소스그림그리기내부클래스 창 Jframe 의모양 (Metal L&F) Jframe 의모양 (Aqua L&F) 창을만드는방법 1. 프레임 (JFrame) 만들기 JFrame frame = new JFrame(); 2. 위젯만들기 JButton button = new JButton( click me );

More information

PowerPoint Presentation

PowerPoint Presentation 자바프로그래밍 1 배열 손시운 ssw5176@kangwon.ac.kr 배열이필요한이유 예를들어서학생이 10 명이있고성적의평균을계산한다고가정하자. 학생 이 10 명이므로 10 개의변수가필요하다. int s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; 하지만만약학생이 100 명이라면어떻게해야하는가? int s0, s1, s2, s3, s4,

More information

비긴쿡-자바 00앞부속

비긴쿡-자바 00앞부속 IT COOKBOOK 14 Java P r e f a c e Stay HungryStay Foolish 3D 15 C 3 16 Stay HungryStay Foolish CEO 2005 L e c t u r e S c h e d u l e 1 14 PPT API C A b o u t T h i s B o o k IT CookBook for Beginner Chapter

More information

Chap12

Chap12 12 12Java RMI 121 RMI 2 121 RMI 3 - RMI, CORBA 121 RMI RMI RMI (remote object) 4 - ( ) UnicastRemoteObject, 121 RMI 5 class A - class B - ( ) class A a() class Bb() 121 RMI 6 RMI / 121 RMI RMI 1 2 ( 7)

More information

untitled

untitled - -, (insert) (delete) - - (insert) (delete) (top ) - - (insert) (rear) (delete) (front) A A B top A B C top push(a) push(b) push(c) A B top pop() top A B D push(d) top #define MAX_STACK_SIZE 100 int

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 오류처리 손시운 ssw5176@kangwon.ac.kr 오류메시지를분석한다. 오류메시지에서많은내용을알수있다. 2 디버깅 디버거를사용하면프로그램에서쉽게오류를감지하고진단할수있다. 디버거는중단점을설정하여서프로그램의실행을제어할수있으며문장 단위로실행하거나변수의값을살펴볼수있다. 3 이클립스에서디버깅 4 이클립스에서디버깅 5 이클립스의디버깅명령어 6 예외처리

More information

JAVA PROGRAMMING 실습 05. 객체의 활용

JAVA PROGRAMMING 실습 05. 객체의 활용 2015 학년도 2 학기 public class Person{ public String name; public int age; public Person(){ public Person(String s, int a){ name = s; age = a; public String getname(){ return name; @ 객체의선언 public static void

More information

Microsoft PowerPoint - 06-Chapter09-Event.ppt

Microsoft PowerPoint - 06-Chapter09-Event.ppt AWT 이벤트처리하기 1. 이벤트처리방식 2. 이벤트클래스와리스너 3. 이벤트어댑터 4. 이벤트의종류 이벤트 (Event) 이벤트 사용자가 UI 컴포넌트에대해취하는행위로인한사건이벤트기반프로그래밍 무한루프를돌면서사용자의행위로인한이벤트를청취하여응답하는형태로작동하는프로그래밍 java.awt.event 이벤트처리 AWT 컴포넌트에서발생하는다양한이벤트를처리하기위한인터페이스와클래스제공

More information

1

1 1 1....6 1.1...6 2. Java Architecture...7 2.1 2SDK(Software Development Kit)...8 2.2 JRE(Java Runtime Environment)...9 2.3 (Java Virtual Machine, JVM)...10 2.4 JVM...11 2.5 (runtime)jvm...12 2.5.1 2.5.2

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 실습 1 배효철 th1g@nate.com 1 목차 조건문 반복문 System.out 구구단 모양만들기 Up & Down 2 조건문 조건문의종류 If, switch If 문 조건식결과따라중괄호 { 블록을실행할지여부결정할때사용 조건식 true 또는 false값을산출할수있는연산식 boolean 변수 조건식이 true이면블록실행하고 false 이면블록실행하지않음 3

More information

A Tour of Java V

A Tour of Java V A Tour of Java V Sungjoo Ha April 3rd, 2015 Sungjoo Ha 1 / 28 Review First principle 문제가생기면침착하게영어로구글에서찾아본다. 타입은가능한값의집합과연산의집합을정의한다. 기본형이아니라면이름표가메모리에달라붙는다. 클래스로사용자정의타입을만든다. 프로그래밍은복잡도관리가중요하다. OOP 는객체가서로메시지를주고받는방식으로프로그램을구성해서복잡도관리를꾀한다.

More information

슬라이드 1

슬라이드 1 UNIT 12 상속과오버라이딩 로봇 SW 교육원 2 기 최상훈 학습목표 2 클래스를상속핛수있다. 메소드오버라이딩을사용핛수있다. 패키지선언과 import 문을사용핛수있다. 상속 (inheritance) 3 상속이란 기존의클래스를기반으로새로운클래스를작성 두클래스를부모와자식으로관계를맺어주는것 자식은부모의모든멤버를상속받음 연관된일렦의클래스에대핚공통적인규약을정의 class

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 클래스와메소드심층연구 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 접근제어 class A { private int a; int b; public int c; // 전용 // 디폴트 // 공용 public class Test { public static void main(string args[]) { A obj = new

More information

No Slide Title

No Slide Title 사건처리와 GUI 프로그래밍 이충기 명지대학교컴퓨터공학과 사건 사건은우리가관심을가질지모르는어떤일이일어나는것을나타내는객체이다. 예를들면, 다음이일어날때프로그램이어떤일을수행해야하는경우에사건이발생한다 : 1. 마우스를클릭한다. 2. 단추를누른다. 3. 키보드의키를누른다. 4. 메뉴항목을선택한다. 2 사건 사건은컴포넌트에서사용자나시스템에의하여발생하는일이다. 자바는사건을나타내는많은사건클래스를제공한다.

More information

JAVA PROGRAMMING 실습 07. 상속

JAVA PROGRAMMING 실습 07. 상속 상속 부모클래스에정의된필드와메소드를자식클래스가물려받는것 슈퍼클래스 (superclass) 특성을물려주는상위클래스 서브클래스 (subclass) 특성을물려받는하위클래스 슈퍼클래스에자신만의특성 ( 필드, 메소드 ) 추가 슈퍼클래스의특성 ( 메소드 ) 을수정 = 오버라이딩구체화 class Phone 전화걸기전화받기 class MobilePhone 전화걸기전화받기무선기지국연결배터리충전하기

More information

슬라이드 1

슬라이드 1 UNIT 16 예외처리 로봇 SW 교육원 3 기 최상훈 학습목표 2 예외처리구문 try-catch-finally 문을사용핛수있다. 프로그램오류 3 프로그램오류의종류 컴파일에러 (compile-time error) : 컴파일실행시발생 럮타임에러 (runtime error) : 프로그램실행시발생 에러 (error) 프로그램코드에의해서해결될수없는심각핚오류 ex)

More information

class Sale void makelineitem(productspecification* spec, int qty) SalesLineItem* sl = new SalesLineItem(spec, qty); ; 2. 아래의액티비티다이어그램을보고 Java 또는 C ++,

class Sale void makelineitem(productspecification* spec, int qty) SalesLineItem* sl = new SalesLineItem(spec, qty); ; 2. 아래의액티비티다이어그램을보고 Java 또는 C ++, Level 1은객관식사지선다형으로출제예정 1. 다음은 POST(Post of Sales Terminal) 시스템의한콜레보레이션다이어그램이다. POST 객체의 enteritem(upc, qty) 와 Sale 객체의 makellineitem(spec,qty) 를 Java 또는 C ++, C # 언어로구현하시오. 각메소드구현과관련하여각객체내에필요한선언이있으면선언하시오.

More information

Microsoft PowerPoint - Lect04.pptx

Microsoft PowerPoint - Lect04.pptx OBJECT ORIENTED PROGRAMMING Object Oriented Programming 이강의록은 Power Java 저자의강의록을사용했거나재편집된것입니다. Class 와 object Class 와객체 클래스의일생 메소드 필드 String Object Class 와객체 3 클래스 클래스의구성 클래스 (l (class): 객체를만드는설계도 클래스로부터만들어지는각각의객체를특별히그클래스의인스턴스

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 4 (Object) (Class) (Instance) (Method) (Constructor) Memory 1 UML 1 @ & 1 (Real World) (Software World) @ &.. () () @ & 2 (Real World) (Software World) OOA/ Modeling Abstraction Instantiation

More information

fundamentalOfCommandPattern_calmglow_pattern_jstorm_1.0_f…

fundamentalOfCommandPattern_calmglow_pattern_jstorm_1.0_f… Command JSTORM http://www.jstorm.pe.kr Command Issued by: < > Revision: Document Information Document title: Command Document file name: Revision number: Issued by: Issue

More information

Let G = (V, E) be a connected, undirected graph with a real-valued weight function w defined on E. Let A be a set of E, possibly empty, that is includ

Let G = (V, E) be a connected, undirected graph with a real-valued weight function w defined on E. Let A be a set of E, possibly empty, that is includ 알고리즘설계와분석 (CSE3081(2 반 )) 기말고사 (2016년 12월15일 ( 목 ) 오전 9시40분 ~) 담당교수 : 서강대학교컴퓨터공학과임인성 < 주의 > 답안지에답을쓴후제출할것. 만약공간이부족하면답안지의뒷면을이용하고, 반드시답을쓰는칸에어느쪽의뒷면에답을기술하였는지명시할것. 연습지는수거하지않음. function MakeSet(x) { x.parent

More information

A Tour of Java III

A Tour of Java III A Tour of Java III Sungjoo Ha March 18th, 2016 Sungjoo Ha 1 / 30 Review First principle 문제가생기면침착하게영어로구글에서찾아본다. 타입은가능한값의집합과연산의집합을정의한다. 기본형이아니라면이름표가메모리에달라붙는다. 클래스로사용자정의타입을만든다. 프로그래밍은복잡도관리가중요하다. OOP 는객체가서로메시지를주고받는방식으로프로그램을구성해서복잡도관리를꾀한다.

More information