Microsoft Word - hci11-midterm-answer.doc

Size: px
Start display at page:

Download "Microsoft Word - hci11-midterm-answer.doc"

Transcription

1 중간고사 담당교수 : 단국대학교멀티미디어공학전공박경신 답은반드시답안지에기술할것. 공간이부족할경우반드시답안지몇쪽의뒤에있다고명기한후기술할것. 그외의경우의답안지뒤쪽이나연습지에기술한내용은답안으로인정안함. 답에는반드시네모를쳐서확실히표시할것. 답안지에학과, 학번, 이름외에본인의암호를기입하면성적공고시학번대신암호를사용할것임. 1. 다음프로그램의실행결과를써라. 전역변수와지역변수에주의할것. (10 점 ) class MethodTest static int i = 5; static void Multiply1(int i) i *= 2; Console.WriteLine("Multiply1 : i=" + i.tostring()); static int Multiply2(int a, int b) int i = 2; i *= 2; Console.WriteLine("Multiply2 : i=" + i.tostring()); Multiply1(i); int c = a * b; Console.WriteLine("Multiply2 : a=0 b=1 c=2", a, b, c); return c; static void Multiply3(int a, int b, ref int c) i *= 2; Console.WriteLine("Multiply3 : i=" + i.tostring()); c = Multiply2(a, b); Console.WriteLine("Multiply3 : c=" + c.tostring()); static void Main() Console.WriteLine("Main1: i=" + i.tostring()); i *= 2; Console.WriteLine("Main2: i=" + i.tostring()); Multiply1(i); 1/13

2 Console.WriteLine("Main3: i=" + i.tostring()); int a = 3, b = 4, c = 6; Multiply3(a, b, ref c); Console.WriteLine("Main4: i=" + i.tostring()); 출력결과 : Main1 : i=5 Main2 : i=10 Multiply1 : i=20 Main3 : i=10 Multiply3 : i=20 Multiply2 : i=4 Multiply1 : i=8 Multiply2 : a=3 b=4 c=12 Multiply3 : c=12 Main4 : i=20 2. StandardWeightCalculator 프로그램의다음메소드들의내부구현을하라. (10 점 ) enum Gender Female, Male enum BMI Underweight, Normal, Overweight, Obesity enum Activity Low, Medium, High // GetGenderFromString 메소드는 str값을남녀에따라 Gender 열거형으로반환 Gender GetGenderFromString(string str) if (str == " 남 " str == "M") return Gender.Male; return Gender.Female; // GetNormalWeight 메소드는남녀별로신장 (cm) 을이용하여표준체중 (kg) 를계산 // 남자표준체중 = 신장 (cm) x 신장 (cm) x 22 x f // 여자표준체중 = 신장 (cm) x 신장 (cm) x 21 x f float GetNormalWeight(float height, Gender gender) if (gender == Gender.Male) return height * height * 22; return height * height * 21; 2/13

3 // GetBMI 메소드는기준에근거하여 BMI 열거형으로반환 // BMI = 체중 (kg)/ 신장^2(m^2) // BMI계산값이 20미만저체중, 20~24 정상, 25~29 과체중, 30이상비만 BMI GetBMI(float height, float weight) float bmi = weight / (height * 0.01f)/ (height * 0.01f); Console.WriteLine("bmi=" + bmi); if (bmi < 20.0) return BMI.Underweight; if (bmi >= 20.0 && bmi < 24.0) return BMI.Normal; if (bmi >= 24.0 && bmi < 30.0) return BMI.Overweight; return BMI.Obesity; // GetActivityFromString 메소드는 str값이 Low/Medium/High에따라 Activity 열거형으로반환 Activity GetActivityFromString(string str) if (str == "Low") return Activity.Low; if (str == "Medium") return Activity.Medium; return Activity.High; 3/13

4 3. 값형식과참조형식에대한 Pass-by-value 와 Pass-by-reference 메소드매개변수전달방식을본인이직접예를들어간단히설명하라. (10 점 ) Pass value type by value ( 값형식을값에의한전달방식 ) - 값형식 (value type) 은값을 copy 하여매개변수에전달 - static void Square1(int x) x*= x; Console.WriteLine( The value inside: 0, x); // 함수내부에선변경된값이출력 static void Main() int i =5; Square1(i); Console.WriteLine( i=0, i); // 그러나, 함수에서변경된값이외부에반영되지않음 Pass reference type by value ( 참조형식을값에의한전달방식 ) - 참조형식 (reference type) 은참조를 copy 하여매개변수에전달 - static void ChangeArray1(int[] arr) arr[0] = 888; // 메인의 myarray 를같이참조하고있으므로 myarray[0]=888 로변경 arr = new int[5] -3, -1, -2, -3, -4; // 함수내부에서 arr 는새로지정 Console.WriteLine( The value inside: arr[0]=0, arr[0]); // 새로지정된배열로출력 static void Main() int[] myarray =1, 4, 5; ChangeArray1(myArray); Console.WriteLine( myarray[0]=0, myarray[0]); // myarry[0]=888 로출력 Pass value type by reference ( 값형식을참조에의한전달방식 ) - ref 키워드를사용하여, 값형식 (value type) 을참조에의한전달방식을사용 - static void Square2(ref int x) x*= x; Console.WriteLine( The value inside: 0, x); // 메인 i 를참조하므로값이변경 static void Main() int i =5; Square2(i); Console.WriteLine( i=0, i); // 함수에서변경된값이외부로반영됨 Pass reference type by reference ( 참조형식을참조에의한전달방식 ) - ref 키워드를사용하여, 참조형식 (reference type) 을참조에의한전달방식을사용 - static void ChangeArray2(ref int[] arr) arr[0] = 888; // 메인의 myarray 를같이참조하고있으므로 myarray[0]=888 로변경 arr = new int[5] -3, -1, -2, -3, -4; // 그러나원본배열이다시변경 Console.WriteLine( The value inside: arr[0]=0, arr[0]); // 새로지정된배열로출력 static void Main() int[] myarray =1, 4, 5; ChangeArray2(myArray); Console.WriteLine( myarray[0]=0, myarray[0]); // myarry[0]=-3 로출력 4/13

5 4. 다음 A 클래스에서포함하는 Size 클래스를정의하라. Size 클래스는 Width 와 Height 속성과생성자와 Print 그리고 ToString 메소드를갖는다. (10 점 ) enum Color Red, Green, Blue abstract class A public Color FillColor public Point Position public Size Size public A(Color fillcolor, Point position, Size size) this.fillcolor = fillcolor; this.position = position; this.size = size; public abstract void Draw(); class Point public int X public int Y public Point() : this(0, 0) public Point(int x, int y) this.x = x; this.y = y; public void SetPosition(int x, int y) this.x = x; this.y = y; public virtual void Print() Console.WriteLine("Point (0,1)", X, Y); public override string ToString() return (String.Format("(0,1)", X, Y)); class Size public int Width public int Height public Size() : this(0, 0) public Size(int width, int height) this.width = width; this.height = height; public virtual void Print() Console.WriteLine("Size (0x1)", Width, Height); public override string ToString() return (String.Format("(0,1)", Width, Height)); 5/13

6 5. 다음 Point3D 클래스와 Point4D 클래스의메소드를모두구현하라. base 와 this 키워드를사용하여코드를간결하게작성한다. (10 점 ) class Point3D : Point public int Z public Point3D() : this(0, 0, 0) public Point3D(int x, int y, int z) : base(x, y) this.z = z; public void SetPosition(int x, int y, int z) base.setposition(x, y); this.z = z; public override void Print() Console.WriteLine("Point3D (0,1,2)", X, Y, Z); public override string ToString() return (String.Format("Point3D (0, 1, 2)", X, Y, Z)); class Point4D : Point3D public int W public Point4D() : this(0, 0, 0, 0) public Point4D(int x, int y, int z, int w) : base(x, y, z) this.w = w; public void SetPosition(int x, int y, int z, int w) base.setposition(x, y, z); this.w = w; public override void Print() Console.WriteLine("Point4D (0,1,2,3)", X, Y, Z, W); public override string ToString() return (String.Format("Point4D (0, 1, 2,3)", X, Y, Z, W)); 6/13

7 6. 다음은 B, C, D, E 클래스를추가적으로보여주고있다. 다형성 (Polymorphism) 이무엇인지예를들어자세히설명하라. 그리고 Main 메소드의출력결과를적어라. (10 점 ) class B : A public B(Color fillcolor, Point position, Size size) : base(fillcolor, position, size) public override void Draw() Console.WriteLine("B 는 (0 1) 에 2x3 크기와 4 색 ", Position.X, Position.Y, Size.Width, Size.Height, FillColor); class C : A public C(Color fillcolor, Point position, Size size) : base(fillcolor, position, size) public override void Draw() Console.WriteLine("C 는 (0 1) 에 2x3 크기와 4 색 ", Position.X, Position.Y, Size.Width, Size.Height, FillColor); class D : A public D(Color fillcolor, Point position, Size size) : base(fillcolor, position, size) public override void Draw() Console.WriteLine("D 는 (0 1) 에 2x3 크기와 4 색 ", Position.X, Position.Y, Size.Width, Size.Height, FillColor); class E : D public E(Color fillcolor, Point position, Size size) : base(fillcolor, position, size) if (size.width < size.height) Size.Height = size.width; Size.Width = size.height; public sealed override void Draw() Console.WriteLine("E 는 (0 1) 에 2x3 크기와 4 색 ", Position.X, Position.Y, Size.Width, Size.Height, FillColor); class Program static void Main(string[] args) A[] alist = new A[5] new C(Color.Red, new Point(0, 0), new Size(10, 30)), new D(Color.Green, new Point(20, 30), new Size(10, 30)), new B(Color.Blue, new Point(30, 40), new Size(20, 30)), new E(Color.Blue, new Point(50, 60), new Size(40, 50)), new D(Color.Blue, new Point(10, 20), new Size(20, 30)) 7/13

8 ; foreach (var elem in alist) elem.draw(); Point p1 = new Point(1, 2); Point3D p2 = new Point3D(10, 11, 12); Point4D p3 = new Point4D(20, 21, 22, 23); Console.WriteLine("p1: 0", p1); Console.WriteLine("p2: 0", p2); Console.WriteLine("p3: 0", p3); p1 = p2; p2 = p3; p1.print(); p2.print(); p3.print(); p2.setposition(4, 5, 6); Console.WriteLine("p2: 0", p2); p3 = (Point4D)p2; Console.WriteLine("p3: 0", p3); Point4D p4 = (Point4D)p3; Console.WriteLine("p4: 0", p4); 다형성 상속을통해클래스를한개이상의형식으로사용할수있는것을다형성이라고 한다. 상위클래스에서선언된메소드를하위클래스에서재정의 (override) 하고실행시간에새로 정의된 override 된멤버의내용으로처리 (late binding) 한다. 예를들어 - p1 = p2; // upcasting; p1 은 Point3D 객체 (10,11,12) p2 = p3; // upcasting; p2 는 Point4D 객체 (20,21,22,23) p2.setposition(4, 5, 6); // p2 가실제 Point4D 객체 (20,21,22,23) 이므로 (4,5,6,23) 로변경 p3 = (Point4D)p2; // downcasting; p2 가실제로 Point4D 객체이므로 p3 도 Point4D 객체 Point4D p4 = (Point4D)p3; // downcasting; p3 가실제로 Point4D 객체이므로 p4 도 Point4D 객체 실행결과 C 는 (0 0) 에 10x30 크기와 Red 색 D 는 (20 30) 에 10x30 크기와 Green 색 B 는 (30 40) 에 20x30 크기와 Blue 색 E 는 (50 60) 에 40x40 크기와 Blue 색 D 는 (10 20) 에 20x30 크기와 Blue 색 p1: (1, 2) p2: (10, 11, 12) p3: (20, 21, 22, 23) Point3D (10, 11, 12) Point4D (20, 21, 22, 23) Point4D (20, 21, 22, 23) p2: (4, 5, 6, 23) p3: (4, 5, 6, 23) p4: (4, 5, 6, 23) 8/13

9 7. 위의 4-6 번예제에서밑줄친 virtual/override 와 abstract/override 그리고 sealed 의차이점이무엇인지예를들어간단히서술하라. (10 점 ) virtual/override : Point, Size 클래스의 public virtual void Print().. 는이클래스를상속받는파생클래스에서이메소드를재정의할수있다는의미로 virtual 로지정한다. Point 를상속받은 Point3D, 그리고 Point3D 를상속받은 Point4D 의 public override void Print().. 에서추가된부분에대한구현을재정의한다. Point, Size, Point3D, Point4D 클래스의 public override void ToString() 는모든클래스가 System.Object 에서상속받아서각클래스에맞게 ToString() 을재정의해서사용한다. abstract/override : 추상클래스 A 에 public abstract void Draw(); 는 abstract 으로지정된메소드로내부구현을할수없다. A 를상속받은 B, C, D, E 클래스의 public override void Draw().. 에서내부구현을해야한다. sealed : E 클래스의 public sealed override void Draw().. 에서는 sealed 하여 E 클래스를상속하여사용하는클래스에서이메소드를더이상재정의해서사용할수없음을지정한다. 8. 위의 Point 클래스를참조하여값형식과참조형식을비교한다. 이프로그램이실행되는출력결과를써라. (10 점 ) static void Main() int val1 = 5; int val2 = 10; if (val1 == val2) Console.WriteLine("val1 == val2"); Console.WriteLine("val1!= val2"); object val3 = val1; object val4 = val1; if (val3 == val4) Console.WriteLine("val3 == val4"); Console.WriteLine("val3!= val4"); int val5 = (int)val3; int val6 = (int)val4; if (val5 == val6) Console.WriteLine("val5 == val6"); Console.WriteLine("val5!= val6"); Point pos1 = new Point(val1, val2); Point pos2 = new Point(val1, val2); if (pos1 == pos2) Console.WriteLine("pos1 == pos2"); Console.WriteLine("pos1!= pos2"); 9/13

10 if (pos1.x == pos2.x) Console.WriteLine("pos1.X == pos2.x"); Console.WriteLine("pos1.X!= pos2.x"); if (pos1.y == pos2.y) Console.WriteLine("pos1.Y == pos2.y"); Console.WriteLine("pos1.Y!= pos2.y"); Point pos3 = pos1; Point pos4 = pos1; if (pos3 == pos4) Console.WriteLine("pos3 == pos4"); Console.WriteLine("pos3!= pos4"); object pos5 = pos3; object pos6 = pos4; if (pos5 == pos6) Console.WriteLine("pos5 == pos6"); Console.WriteLine("pos5!= pos6"); Point pos7 = (Point) pos6; if (pos1 == pos7) Console.WriteLine("pos1 == pos7"); Console.WriteLine("pos1!= pos7"); if (pos2 == pos7) Console.WriteLine("pos2 == pos7"); Console.WriteLine("pos2!= pos7"); Console.WriteLine(); 출력결과 : val1!= val2 val3!= val4 val5 == val6 pos1!= pos2 pos1.x == pos2.x pos1.y == pos2.y pos3 == pos4 pos5 == pos6 pos1 == pos7 pos2!= pos7 10/13

11 9. IEquatable 와 IComparable 인터페이스를간단히설명하라. 다음 Point 클래스에 IEquatable<T> 와 IComparable<T> 인터페이스를상속받아구현 (implement) 하라. (10 점 ) interface IEquatable<T> bool Equals(T obj); interface IComparable<T> int CompareTo(T obj); class Point : IEquatable<Point>, IComparable<Point> // 중간생략 // Point 클래스의 X 와 Y 가모두같으면 true 아니면 false public bool Equals(Point other) if (this.x == other.x && this.y == other.y) return true; return false; // Point 클래스의 X 가같으면 Y 가누가더큰지를비교 public int CompareTo(Point other) if (this.x == other.x) return this.y.tocompare(other.y); return this.x.tocompare(other.x); IEquatable 인터페이스 : IEquatable 인터페이스는현객체가동일한형태의다른객체와같은지여부를확인하는 Equals 메소드를제공하는인터페이스로, 현객체가 obj 인수의값과같으면 true, 다르면 false를반환하도록구현한다. == 와!= 연산자오버로딩이함께되어있을때두객체의내용이같은지비교하는데사용된다. IComparable 인터페이스 : IComparable 인터페이스는현객체를동일한형식의다른객체와비교하는 ( 인터페이스정렬순서를확인하는 ) CompareTo 메소드를제공하는인터페이스로, 현객체가 obj 인수보다작으면 0보다작은수를같으면 0을그면 0보다큰수를반환하도록구현한다. 컬렉션을사용할시 Sort ( 정렬 ) 할때사용된다. 11/13

12 10. 다음 Main 메소드에밑줄친네줄의코드를 TestA, TestB, Print, PrintThree 메소드를사용하여수정하라. (5 점 ) class NumValue public int A public static int B public const int THREE=3; public NumValue(int a, int b) A = a; B = b; public bool TestA(int value) return A > value; public static bool TestB(int value) return B == value; public void Print() Console.WriteLine("a=0 b=1", A, B); public static void PrintThree() Console.WriteLine("Three!"); class NumValueTest static void Main() NumValue n = new NumValue(5, 3); if (n.a > NumValue.THREE) Console.WriteLine("a=0 b=1", n.a, NumValue.B); if (NumValue.B == NumValue.THREE) Console.WriteLine("Three!"); if (n.testa(numvalue.three)) n.print(); if (NumValue.TestB(NumValue.THREE)) NumValue.PrintThree(); 12/13

13 11. 다음은원하는온도변환방법을지정하여사용할수있는프로그램이다. 빈칸을채워라. (5 점 ) public delegate double Conversion(double from); class DelegateTest static double F2C( double f ) return (f ) * (5.0 / 9.0); static double C2F( double c ) return ((9.0 / 5.0) * c ); // factory method for returning delegate static public Conversion GetConversionMethod(string conversiontype) Conversion conversion; switch (conversiontype) case "C2F": conversion = new Conversion(C2F); break; case "F2C": conversion = new Conversion(F2C); break; default: throw new ArgumentException(" 알수없는 conversion type: "+conversiontype); return conversion; // user input to temperature and type of conversion static public void GetUserInput(out double temperature, out string conversiontype) Console.WriteLine("Temperature Converter"); Console.WriteLine("C2F: Celsius => Fahrenheit"); Console.WriteLine("F2C: Fahrenheit => Celsius"); Console.Write(" 원하는온도변환을입력하시오 (C2F or F2C): "); conversiontype = Console.ReadLine(); Console.Write(" 변환하고자하는온도를입력하시오 : "); temperature = Double.Parse(Console.ReadLine()); static public void Main() double temperature; string conversiontype; GetUserInput(out temperature, out conversiontype); Conversion doconversion = GetConversionMethod(conversionType); double result = doconversion(temperature); Console.WriteLine("\n conversiontype=0 Temperature=1 Result=2\n", conversiontype, temperature, result); - 끝 - 13/13

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

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

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

JAVA PROGRAMMING 실습 08.다형성

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

More information

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

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

More information

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

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

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

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

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

금오공대 컴퓨터공학전공 강의자료

금오공대 컴퓨터공학전공 강의자료 C 프로그래밍프로젝트 Chap 14. 포인터와함수에대한이해 2013.10.09. 오병우 컴퓨터공학과 14-1 함수의인자로배열전달 기본적인인자의전달방식 값의복사에의한전달 val 10 a 10 11 Department of Computer Engineering 2 14-1 함수의인자로배열전달 배열의함수인자전달방식 배열이름 ( 배열주소, 포인터 ) 에의한전달 #include

More information

Microsoft PowerPoint - 2강

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

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

Microsoft Word - cg07-midterm.doc

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

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 Template

PowerPoint Template 16-1. 보조자료템플릿 (Template) 함수템플릿 클래스템플릿 Jong Hyuk Park 함수템플릿 Jong Hyuk Park 함수템플릿소개 함수템플릿 한번의함수정의로서로다른자료형에대해적용하는함수 예 int abs(int n) return n < 0? -n : n; double abs(double n) 함수 return n < 0? -n : n; //

More information

Microsoft PowerPoint - CSharp-2-기초문법

Microsoft PowerPoint - CSharp-2-기초문법 2 장. C# 기초문법 자료형 제어문 배열 연산자 순천향대학교컴퓨터학부이상정 1 자료형 순천향대학교컴퓨터학부이상정 2 CTS CTS(Common Type System) 닷넷기반의여러언어에서공통으로사용되는자료형 언어별로서로다른자료형을사용할때발생할수있는호환성문제를해결 값 (Value) 형과참조 (Reference) 형을지원 CTS가제공하는모든자료형은 System.Object를상속받아구현

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

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

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

More information

Microsoft PowerPoint - additional01.ppt [호환 모드]

Microsoft PowerPoint - additional01.ppt [호환 모드] 1.C 기반의 C++ part 1 함수 오버로딩 (overloading) 디폴트매개변수 (default parameter) 인-라인함수 (in-line function) 이름공간 (namespace) Jong Hyuk Park 함수 Jong Hyuk Park 함수오버로딩 (overloading) 함수오버로딩 (function overloading) C++ 언어에서는같은이름을가진여러개의함수를정의가능

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

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

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

Modern Javascript

Modern Javascript ES6 - Arrow Function Class Template String Destructuring Default, Rest, Spread let, const for..of Promises Module System Map, Set * Generator * Symbol * * https://babeljs.io/ Babel is a JavaScript compiler.

More information

쉽게 풀어쓴 C 프로그래밍

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

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 프레젠테이션

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

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

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

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

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

자바 프로그래밍

자바 프로그래밍 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

PowerPoint Presentation

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

More information

초보자를 위한 C# 21일 완성

초보자를 위한 C# 21일 완성 C# 21., 21 C#., 2 ~ 3 21. 2 ~ 3 21.,. 1~ 2 (, ), C#.,,.,., 21..,.,,, 3. A..,,.,.. Q&A.. 24 C#,.NET.,.,.,. Visual C# Visual Studio.NET,..,. CD., www. TeachYour sel f CSharp. com., ( )., C#.. C# 1, 1. WEEK

More information

<4D F736F F F696E74202D20C1A63038C0E520C5ACB7A1BDBABFCD20B0B4C3BC4928B0ADC0C729205BC8A3C8AF20B8F0B5E55D>

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

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 제 11 장상속 1. 상속의개념을이해한다. 2. 상속을이용하여자식클래스를작성할수있다. 3. 상속과접근지정자와의관계를이해한다. 4. 상속시생성자와소멸자가호출되는순서를이해한다. 이번장에서만들어볼프로그램 class Circle { int x, y; int radius;... class Rect { int x, y; int width, height;... 중복 상속의개요

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 제 5 장생성자와접근제어 1. 객체지향기법을이해한다. 2. 클래스를작성할수있다. 3. 클래스에서객체를생성할수있다. 4. 생성자를이용하여객체를초기화할수 있다. 5. 접근자와설정자를사용할수있다. 이번장에서만들어볼프로그램 생성자 생성자 (constructor) 는초기화를담당하는함수 생성자가필요한이유 #include using namespace

More information

Microsoft PowerPoint - hci2-lecture6 [호환 모드]

Microsoft PowerPoint - hci2-lecture6 [호환 모드] Overview 상속성 & 참조형 321190 2012 년가을학기 9/26/2012 박경신 상속개념이해및파생클래스작성 Has-a Model 메소드재정의이해 추상클래스와봉인클래스의이해 인터페이스기능이해 형변환이해 값형과참조형의비교 Inheritance 상속 (Inheritance) 란상위클래스의기능과속성을하위클래스에게그대로물려주는것을의미 상위클래스를부모 / 기반클래스

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

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 Word - \301\337\260\243\260\355\273\347.docx)

(Microsoft Word - \301\337\260\243\260\355\273\347.docx) 내장형시스템공학 (NH466) 중간고사 학번 : 이름 : 문제 배점 점수 1 20 2 20 3 20 4 20 5 10 6 10 7 15 8 20 9 15 합계 150 1. (20 점 ) 다음용어에대해서설명하시오. (1) 정보은닉 (Information Hiding) (2) 캡슐화 (Encapsulation) (3) 오버로딩 (Overloading) (4) 생성자

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 프레젠테이션

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

중간고사

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

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

선형대수학 Linear Algebra

선형대수학  Linear Algebra 배열, 컬렉션, 인덱서 array, collection, indexer 소프트웨어학과 HCI 프로그래밍강좌 배열 배열 (array) 동일한자료형을다수선언 선언형식 데이터형식 [ ] 배열이름 = new 데이터형식 [ 개수 ]; int[ ] array = new int[5]; 인덱스 (index) 는 0 에서시작 scores[0] = 80; scores[1] =

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

PowerPoint 프레젠테이션

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

More information

Microsoft PowerPoint - additional08.ppt [호환 모드]

Microsoft PowerPoint - additional08.ppt [호환 모드] 8. 상속과다형성 (polymorphism) 상속된객체와포인터 / 참조자의관계 정적바인딩과동적바인딩 virtual 소멸자 Jong Hyuk Park 상속의조건 public 상속은 is-a 관계가성립되도록하자. 일반화 ParttimeStd 구체화 2 상속의조건 잘못된상속의예 현실세계와완전히동떨어진모델이형성됨 3 상속의조건 HAS-A( 소유 ) 관계에의한상속!

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

chap10.PDF

chap10.PDF 10 C++ Hello!! C C C++ C++ C++ 2 C++ 1980 Bell Bjarne Stroustrup C++ C C++ C, C++ C C 3 C C++ (prototype) (type checking) C C++ : C++ 4 C C++ (prototype) (type checking) [ 10-1] #include extern

More information

Microsoft PowerPoint - CSharp-10-예외처리

Microsoft PowerPoint - CSharp-10-예외처리 10 장. 예외처리 예외처리개념 예외처리구문 사용자정의예외클래스와예외전파 순천향대학교컴퓨터학부이상정 1 예외처리개념 순천향대학교컴퓨터학부이상정 2 예외처리 오류 컴파일타임오류 (Compile-Time Error) 구문오류이기때문에컴파일러의구문오류메시지에의해쉽게교정 런타임오류 (Run-Time Error) 디버깅의절차를거치지않으면잡기어려운심각한오류 시스템에심각한문제를줄수도있다.

More information

JAVA PROGRAMMING 실습 02. 표준 입출력

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

More information

1. 객체의생성과대입 int 형변수 : 선언과동시에초기화하는방법 (C++) int a = 3; int a(3); // 기본타입역시클래스와같이처리가능 객체의생성 ( 복습 ) class CPoint private : int x, y; public : CPoint(int a

1. 객체의생성과대입 int 형변수 : 선언과동시에초기화하는방법 (C++) int a = 3; int a(3); // 기본타입역시클래스와같이처리가능 객체의생성 ( 복습 ) class CPoint private : int x, y; public : CPoint(int a 6 장복사생성자 객체의생성과대입객체의값에의한전달복사생성자디폴트복사생성자복사생성자의재정의객체의값에의한반환임시객체 C++ 프로그래밍입문 1. 객체의생성과대입 int 형변수 : 선언과동시에초기화하는방법 (C++) int a = 3; int a(3); // 기본타입역시클래스와같이처리가능 객체의생성 ( 복습 ) class CPoint private : int x, y;

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

Microsoft PowerPoint - C++ 5 .pptx

Microsoft PowerPoint - C++ 5 .pptx C++ 언어프로그래밍 한밭대학교전자. 제어공학과이승호교수 연산자중복 (operator overloading) 이란? 2 1. 연산자중복이란? 1) 기존에미리정의되어있는연산자 (+, -, /, * 등 ) 들을프로그래머의의도에맞도록새롭게정의하여사용할수있도록지원하는기능 2) 연산자를특정한기능을수행하도록재정의하여사용하면여러가지이점을가질수있음 3) 하나의기능이프로그래머의의도에따라바뀌어동작하는다형성

More information

(8) getpi() 함수는정적함수이므로 main() 에서호출할수있다. (9) class Circle private double radius; static final double PI= ; // PI 이름으로 로초기화된정적상수 public

(8) getpi() 함수는정적함수이므로 main() 에서호출할수있다. (9) class Circle private double radius; static final double PI= ; // PI 이름으로 로초기화된정적상수 public Chapter 9 Lab 문제정답 1. public class Circle private double radius; static final double PI=3.141592; // PI 이름으로 3.141592 로초기화된정적상수 (1) public Circle(double r) radius = r; (2) public double getradius() return

More information

슬라이드 1

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

More information

C++ Programming

C++ Programming C++ Programming 연산자다중정의 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 연산자다중정의 C++ 스타일의문자열 2 연산자다중정의 연산자다중정의 단항연산자다중정의 이항연산자다중정의 cin, cout 그리고 endl C++ 스타일의문자열 3 연산자다중정의 연산자다중정의 (Operator

More information

슬라이드 1

슬라이드 1 -Part3- 제 4 장동적메모리할당과가변인 자 학습목차 4.1 동적메모리할당 4.1 동적메모리할당 4.1 동적메모리할당 배울내용 1 프로세스의메모리공간 2 동적메모리할당의필요성 4.1 동적메모리할당 (1/6) 프로세스의메모리구조 코드영역 : 프로그램실행코드, 함수들이저장되는영역 스택영역 : 매개변수, 지역변수, 중괄호 ( 블록 ) 내부에정의된변수들이저장되는영역

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

PowerPoint Presentation

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

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

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 클래스, 객체, 메소드 손시운 ssw5176@kangwon.ac.kr 실제세계는객체로이루어진다. 2 객체와메시지 3 객체지향이란? 실제세계를모델링하여소프트웨어를개발하는방법 4 객체 5 객체란? 객체 (Object) 는상태와동작을가지고있다. 객체의상태 (state) 는객체의특징값 ( 속성 ) 이다. 객체의동작 (behavior) 또는행동은객체가취할수있는동작

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

K&R2 Reference Manual 번역본

K&R2 Reference Manual 번역본 typewriter structunion struct union if-else if if else if if else if if if if else else ; auto register static extern typedef void char short int long float double signed unsigned const volatile { } struct

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 제 3 장함수와문자열 1. 함수의기본적인개념을이해한다. 2. 인수와매개변수의개념을이해한다. 3. 함수의인수전달방법 2가지를이해한다 4. 중복함수를이해한다. 5. 디폴트매개변수를이해한다. 6. 문자열의구성을이해한다. 7. string 클래스의사용법을익힌다. 이번장에서만들어볼프로그램 함수란? 함수선언 함수호출 예제 #include using

More information

ThisJava ..

ThisJava .. 자바언어에정확한타입을추가한 ThisJava 소개 나현익, 류석영 프로그래밍언어연구실 KAIST 2014 년 1 월 14 일 나현익, 류석영 자바언어에정확한타입을추가한 ThisJava 소개 1/29 APLAS 2013 나현익, 류석영 자바 언어에 정확한 타입을 추가한 ThisJava 소개 2/29 실제로부딪힌문제 자바스크립트프로그램분석을위한요약도메인 나현익,

More information

No Slide Title

No Slide Title 상속 이충기 명지대학교컴퓨터공학과 상속 Q: 건설회사는기존아파트와조금다르거나추가적인특징들을가진새아파트를지을때어떻게하는가? A: 2 상속 상속 (inheritance) 은클래스들을연관시키는자연스럽고계층적인방법이다. 상속은객체지향프로그래밍의가장중요한개념중의하나이다. 상속은 은 이다 라는관계 (is-a relationship) 를나타낸다. 이관계를적용하여클래스들을상하관계로연결하는것이상속이다.

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

More information

C++ Programming

C++ Programming C++ Programming 클래스와데이터추상화 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 객체지향프로그래밍 클래스와객체 2 객체지향프로그래밍 객체지향언어 (Object-Oriented Language) 프로그램을명령어의목록으로보는시각에서벗어나여러개의 독립된단위, 즉 객체 (Object) 들의모임으로파악

More information

17장 클래스와 메소드

17장 클래스와 메소드 17 장클래스와메소드 박창이 서울시립대학교통계학과 박창이 ( 서울시립대학교통계학과 ) 17 장클래스와메소드 1 / 18 학습내용 객체지향특징들객체출력 init 메소드 str 메소드연산자재정의타입기반의버전다형성 (polymorphism) 박창이 ( 서울시립대학교통계학과 ) 17 장클래스와메소드 2 / 18 객체지향특징들 객체지향프로그래밍의특징 프로그램은객체와함수정의로구성되며대부분의계산은객체에대한연산으로표현됨객체의정의는

More information

Microsoft PowerPoint - Chapter 6.ppt

Microsoft PowerPoint - Chapter 6.ppt 6.Static 멤버와 const 멤버 클래스와 const 클래스와 static 연결리스트프로그램예 Jong Hyuk Park 클래스와 const Jong Hyuk Park C 의 const (1) const double PI=3.14; PI=3.1415; // 컴파일오류 const int val; val=20; // 컴파일오류 3 C 의 const (1)

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

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

4장.문장

4장.문장 문장 1 배정문 혼합문 제어문 조건문반복문분기문 표준입출력 입출력 형식화된출력 [2/33] ANSI C 언어와유사 문장의종류 [3/33] 값을변수에저장하는데사용 형태 : < 변수 > = < 식 > ; remainder = dividend % divisor; i = j = k = 0; x *= y; 형변환 광역화 (widening) 형변환 : 컴파일러에의해자동적으로변환

More information

C++ Programming

C++ Programming C++ Programming 예외처리 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 예외처리 2 예외처리 예외처리 C++ 의예외처리 예외클래스와객체 3 예외처리 예외를처리하지않는프로그램 int main() int a, b; cout > a >> b; cout

More information

Chapter 6 Objects and Classes

Chapter 6 Objects and Classes 11 장상속과다형성 1 강의목표 상속 (inheritance) 을이용하여기본클래스 (base class) 로부터파생클래스 (derived class) 생성 (11.2) 파생클래스유형의객체를기본클래스유형의매개변수 (parameter) 로전달함으로써일반화프로그래밍 (generic programming) 작업 (11.3) 생성자와소멸자의연쇄적처리 (chaining)

More information

유니티 변수-함수.key

유니티 변수-함수.key C# 1 or 16 (Binary or Hex) 1:1 C# C# (Java, Python, Go ) (0101010 ). (Variable) : (Value) (Variable) : (Value) ( ) (Variable) : (Value) ( ) ; (Variable) : (Value) ( ) ; = ; (Variable) : (Value) (Variable)

More information

JAVA PROGRAMMING 실습 07. 상속

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

More information

0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x = (12 + 6) / 2 * 3; x = 27 x = 3 * (8 / 4

0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x = (12 + 6) / 2 * 3; x = 27 x = 3 * (8 / 4 Introduction to software design 2012-1 Final 2012.06.13 16:00-18:00 Student ID: Name: - 1 - 0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x

More information

Microsoft PowerPoint - 07-C#-2-기초문법.ppt [호환 모드]

Microsoft PowerPoint - 07-C#-2-기초문법.ppt [호환 모드] 기본자료형 연산자와제어문 배열 컬렉션과반복자 순천향대학교컴퓨터학부이상정 1 기본자료형 순천향대학교컴퓨터학부이상정 2 C# 자료형 C# 은.NET 프레임워크가제공하는 CTS(Common Type System) 자료형을사용 CTS는닷넷기반의여러언어에서공통으로사용되는자료형 CTS 는값 (value) 형과참조형 (reference) 형지원 CTS가제공하는모든데이터형은

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

PowerPoint 프레젠테이션

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

More information

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt 변수와상수 1 변수란무엇인가? 변수 : 정보 (data) 를저장하는컴퓨터내의특정위치 ( 임시저장공간 ) 메모리, register 메모리주소 101 번지 102 번지 변수의크기에따라 주로 byte 단위 메모리 2 기본적인변수형및변수의크기 변수의크기 해당컴퓨터에서는항상일정 컴퓨터마다다를수있음 short

More information

TEST BANK & SOLUTION

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

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

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

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

01-OOPConcepts(2).PDF

01-OOPConcepts(2).PDF Object-Oriented Programming Concepts Tel: 02-824-5768 E-mail: hhcho@selabsoongsilackr? OOP (Object) (Encapsulation) (Message) (Class) (Inheritance) (Polymorphism) (Abstract Class) (Interface) 2 1 + = (Dependency)

More information

슬라이드 1

슬라이드 1 정적메모리할당 (Static memory allocation) 일반적으로프로그램의실행에필요한메모리 ( 변수, 배열, 객체등 ) 는컴파일과정에서결정되고, 실행파일이메모리에로드될때할당되며, 종료후에반환됨 동적메모리할당 (Dynamic memory allocation) 프로그램의실행중에필요한메모리를할당받아사용하고, 사용이끝나면반환함 - 메모리를프로그램이직접관리해야함

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

비긴쿡-자바 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

JAVA PROGRAMMING 실습 09. 예외처리

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

More information

Microsoft PowerPoint - lec2.ppt

Microsoft PowerPoint - lec2.ppt 2008 학년도 1 학기 상지대학교컴퓨터정보공학부 고광만 강의내용 어휘구조 토큰 주석 자료형기본자료형 참조형배열, 열거형 2 어휘 (lexicon) 어휘구조와자료형 프로그램을구성하는최소기본단위토큰 (token) 이라부름문법적으로의미있는최소의단위컴파일과정의어휘분석단계에서처리 자료형 자료객체가갖는형 구조, 개념, 값, 연산자를정의 3 토큰 (token) 정의문법적으로의미있는최소의단위예,

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

설계란 무엇인가?

설계란 무엇인가? 금오공과대학교 C++ 프로그래밍 jhhwang@kumoh.ac.kr 컴퓨터공학과 황준하 6 강. 함수와배열, 포인터, 참조목차 함수와포인터 주소값의매개변수전달 주소의반환 함수와배열 배열의매개변수전달 함수와참조 참조에의한매개변수전달 참조의반환 프로그래밍연습 1 /15 6 강. 함수와배열, 포인터, 참조함수와포인터 C++ 매개변수전달방법 값에의한전달 : 변수값,

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

Microsoft PowerPoint 세션.ppt

Microsoft PowerPoint 세션.ppt 웹프로그래밍 () 2006 년봄학기 문양세강원대학교컴퓨터과학과 세션변수 (Session Variable) (1/2) 쇼핑몰장바구니 장바구니에서는사용자가페이지를이동하더라도장바구니의구매물품리스트의내용을유지하고있어야함 PHP 에서사용하는일반적인변수는스크립트의수행이끝나면모두없어지기때문에페이지이동시변수의값을유지할수없음 이러한문제점을해결하기위해서 PHP 에서는세션 (session)

More information

C++ Programming

C++ Programming C++ Programming 상속과다형성 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 상속의이해 상속과다형성 다중상속 2 상속과다형성 객체의이해 상속클래스의객체의생성및소멸 상속의조건 상속과다형성 다중상속 3 상속의이해 상속 (Inheritance) 클래스에구현된모든특성 ( 멤버변수와멤버함수 )

More information

Microsoft PowerPoint - additional06.ppt [호환 모드]

Microsoft PowerPoint - additional06.ppt [호환 모드] 보조자료 6.Static 멤버와 const 멤버 클래스와 const 클래스와 static 연결리스트프로그램예 Jong Hyuk Park 클래스와 const Jong Hyuk Park 복습 : Const 키워드왜사용? C 의 const (1) const double PI=3.14; PI=3.1415; // 컴파일오류 const int val; val=20; //

More information