2008spring_final - - 1 - 1 (30) 2 (30) 3 (30) 4 (30) 5 (30)...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: - 1 - 1 (30) 2 (30) 3 (30) 4 (30) 5 (30) Total (150) CS101 Introduction to Programming Final Exam (Spring 2008) Section Professor's Name Student ID Your Name ※ Fill out the student information CORRECTLY or you will get 1 point off for every mistake you make. 1. Answer each question according to the instruction. 1-1. Choose one that is NOT a Java keyword (or reserved word). ( 4 ) (3 points) ① implements ② interface ③ throw ④ integer ⑤ abstract 1-2. What result will you get when the following program is executed? ( 4 ) (3 points) public class test { public static void main(String[] args) { StringTokenizer st = new StringTokenizer("3+4-5+10", "+-", true); for(int i=0; i<st.countTokens(); i++) System.out.print(st.nextToken()+" "); } } ① 3 4 5 10 ② 3 + 4 - 5 + 10 ③ 3 4 ④ 3 + 4 - ⑤ This program throws a “NoSuchElementException" 1-3. Choose a correct statement. ( 4 ) (3 points) ① An abstract class can contain only abstract methods ② Although we can make an object for an abstract class, it is impossible to make an object for an interface ③ It is impossible that a class inherits a parent class and also implements an interface. ④ 'actionPerformed()' is an abstract method defined in 'ActionListener' and 'ActionListener' is a kind of interface ⑤ When a class inherits an abstract class or interface, we use a word 'implements' instead of 'extends'- 2 - 1-4. The following program handles the exception by using the try-catch statement. Choose an answer that represent a correct result you will get after execution. ( 1 ) (3 points) public class test { public static void main(String[] args) { System.out.print("1"); try { System.out.print("-2"); methodA(); System.out.print("-3"); } catch(NullPointerException e) { System.out.print("-4"); System.exit(0); } catch(Exception e) { System.out.print("-5"); } finally { System.out.print("-6"); } } public static void methodA() throws Exception { int a = 3; if(a%2==1) throw new NullPointerException(); System.out.print("-7"); } } ① 1-2-4 ② 1-2-5 ③ 1-2-4-6 ④ 1-2-5-6 ⑤ 1-2-7-3-6 1-5. Choose an incorrect description. ( 4 ) (3 points) ① Vector and Linked List are a kind of dynamic data structures. ② At the time an array is created, its length is fixed. ③ The base type of a vector must be a class type rather than a primitive type. ④ In Generics, it is possible to create a new object by using type parameters (such as <T>); For example, T s = new T(); is a legal expression. ⑤ A valid array index is always between 0 and (array length - 1)- 3 - * The following program prints out an integer value written in the file "input.txt". Read this program and answer two questions below. (1-6, 1-7) public class test { public static void main(String[] args) { try{ BufferedReader br = new BufferedReader(new FileReader("input.txt")); String s = br.readLine(); System.out.println(Integer.parseInt(s)); } catch (NumberFormatException e) { System.out.println("number format error"); } catch (FileNotFoundException e) {...
View Full 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 / 22

2008spring_final - - 1 - 1 (30) 2 (30) 3 (30) 4 (30) 5 (30)...

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

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