test3soln - ECE 462 Fall 2011, Third Exam DO NOT START...

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

View Full Document Right Arrow Icon
ECE 462 Fall 2011, Third Exam DO NOT START WORKING ON THIS UNTIL TOLD TO DO SO. You have until 9:20 to take this exam. Your exam should have 12 pages total (including this cover sheet). Please let Prof. Midkiff know immediately if it does not. This exam is open book, open notes, but no electronics. If you have a question, please ask for clarification. If the question is not resolved, state on the test whatever assumptions you need to make to answer the question, and answer it under those assumptions. Check the front board occasionally for corrections. Name: Student ID:
Background image of page 1

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

View Full DocumentRight Arrow Icon
Q1 (7 pts): Circle the most true of the following. The answer in bold is the correct one. In Java, a function may throw at most one type of exception. In Java, an integer can be thrown as an exception In Java, exceptions are asynchronous, and classes for objects that are thrown must extend Thread or implement Runnable In Java, any object can be thrown as an exception In Java, classes for objects that are thrown by exceptions must extend Exception In Java exception must be caught by the immediately surrounding try-catch block, or by the immediate caller, otherwise the program terminates. Q2 (7 pts): Circle the most true of the following. The ansswer in bold is the correct one. C++, the code inside finally is executed only when an exception has not occurred. The same C++ function may throw different types of exceptions. In C++, the code inside a catch clause cannot throw any exception. In C++, each try has one and only one corresponding catch. In C++, a function called inside a try block must throw an exception.
Background image of page 2
Q3 (7 pts): What is printed by the following program: 1 Exception caught in f1 in Finally class Q3 { static void f(int j) throws Exception { System.out.println( j ); if (j > 0) throw new Exception(); f( ++j ); } static void f1(int j) throws Exception { try { f(1); } catch(Exception e ) { System.out.println("Exception caught in f1"); } finally { System.out.println("in Finally"); } } public static void main( String[] args ) { try { f1(0); } catch(Exception e ) { System.out.println("Exception caught in main"); } } }
Background image of page 3

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

View Full DocumentRight Arrow Icon
Q4 (7 pts): Either say what is printed by the program below, or write “bad program” if it receives an error because the type of the thrown exception, and the type in the catch clause, are not the same. 1
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 02/19/2012 for the course ECE 462 taught by Professor Samuelmidkiff during the Fall '11 term at Purdue University-West Lafayette.

Page1 / 12

test3soln - ECE 462 Fall 2011, Third Exam DO NOT START...

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