(a)



Florida International University COP3804 .

Question 1 What digits, and in what order, will they be printed when the following program is executed?

public class MyException

{

Static int k;

public static void main(String arg[])

{

try

{

int i = 5/k;

}

catch(ArithmeticException e)

{

System.out.println("1");

}

catch(RuntimeException e)

{

System.out.println("2");

}

catch(Exception e)

{

System.out.println("3");

}

finally

{

System.out.println("4");

}

System.out.println("5");

}

}

Question 2 Use the concept of stack to convert the following infix expression to postfix expression.

10 + ( 30 – 5 * 2 ) /5

Show the state of the stack and the state of the postfix string after each item is read from the infix string.

Question3

Use the concept of stack to evaluate the following postfix expression. Show the state of the stack after each item is read from the postfix string.

10 50 10 2 * - 6 / +

Question 6 Show the screen output from the program assuming that it runs without error.

(Place your answer to the right of the code)

import java.util.*;

public class Review

{

public static void main(String [] arg)

{

Vector myvec = new Vector(20);

Stack stack = new Stack();

for(int j=0,i=5; i ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download