2007spring_final - 1 2 3 4 Total CS101 Introduction to...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
~ 1 ~ 1 2 3 4 Total CS101 Introduction to Programming Final Exam (2007 Spring) * Fill out the student information COMPLETELY. Section (class) (from A to L) Student ID Name * Students may ask the supervisor (TA) to translate the English words or sentences into Korean. * Students may write the answer either in English or Korean. 1. Answer each question by following the instruction. 1-1. Fill out the box with O if the answer is yes and with X for otherwise. (1 point for each question) Q u e s t i o n O / X ex. JAVA is one of programming languages O (1) If you are defining a derived class, you can directly access a private instance variable of the base class. X (2) If you are defining a derived class, you can use a public method of the base class. O (3) The following is legal. Exception cs101 = new Exception(“Final Exam”); O (4) Binary files are thought of as a sequence of characters and have streams and methods to make the binary digits look like characters to your program and your editor. X (5) An event in a graphical user interface is an object which represents some action such as clicking a mouse, dragging the mouse, or pressing a key on the keyboard. O
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
1-2. Choose proper answer among the answer list. (2 points for each blank) Answer list (1) ~ (3) Using the inheritance concept, find proper keywords. (4) ~ (8) In this program, we make a new file, and write something. Fill out the blanks. (a) open (b) close (c) FileWriter (d) readLine (e) io (f) extends (g) finish (h) implements (i) swing (j) interface (k) finally (l) util (m) Exception (n) outputStreamWriter (o) catch (p) class (q) abstract (r) BufferedReader (s) try (t) FileReader (u) FileNotFoundException (v) this (w) lang (x) super //Writable.java public (1) (j) Writable { public String toString(); } //WritableClass.java public (2) (p) as e WritableClass (3) (h) e Writable { public String toString( ) { return "final exam"; } } //TestSaveFile.java import java. (4) (e) cas e .*; public class TestSaveFile { public static void main(String[] args) { (5) (s) ca e { PrintWriter pw = new PrintWriter(new FileWriter ("output.txt")); for(int i=1; i<=3; i++) { pw.println(i+"th Line in File"); } p w . (6) (b) e (); } (7) (o) e ( (8) (m) e e) { System.out.println("io error"); }
Background image of page 2
~ 3 ~ 1-3. The following is for sorting an array using the bubble sort algorithm. (Remind the second homework.) Fill out the blanks. You should handle the case that the size ar is not 5, but another value. (2 points for each blank) 1-4. What is the output result of the following program? (3 points) ① 0 ② 1 ③ 2 ④ true ⑤ false int [] ar = {3,5,2,4,1}; for (int i=0; i < (1) ar.length - 1 cas e ; i++) { for (int j=0; j < (2) ar.length –i - 1 case ; j++) { i f ( (3) ar[j] < ar[j+1] ase ) { i n t b = a r [ j ] ; a r [ j ] = a r [ j + 1 ] ; a r [ j + 1 ] = b ; } } } /* After sorting, ar[0] = 5, ar[1] = 4, ar[2] = 3, ar[3] = 2, ar[4] = 1 */ //TestToken.java import java.util.*; public class TestToken { public static void main(String[] args) { StringTokenizer a = new StringTokenizer("This is CS101"); a.nextToken(); a.nextToken(); a.hasMoreTokens(); System.out.println(a.countTokens()); } }
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
~ 4 ~ 2. Read the following classes, and answer questions.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/09/2010 for the course CS CS101 taught by Professor Hwang during the Spring '10 term at 카이스트, 한국과학기술원.

Page1 / 16

2007spring_final - 1 2 3 4 Total CS101 Introduction to...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online