Question: Which digits, and in which order, will be printed when the following program is run? Select the one correct answer. (a) The program will only

Which digits, and in which order, will be printed when the following program is run?

public class DemoClass { public static void main(String[]args) { int k=0; }

Select the one correct answer.

(a) The program will only print 5.

(b) The program will only print 1 and 4, in that order.

(c) The program will only print 1, 2, and 4, in that order.

(d) The program will only print 1, 4, and 5, in that order.

(e) The program will only print 1, 2, 4, and 5, in that order.

(f) The program will only print 3 and 5, in that order.

public class DemoClass { public static void main(String[]args) { int k=0; } } try { int i = 5/k; } catch (ArithmeticException e) { System.out.println("1"); { } catch (RuntimeException e) System.out.println("2"); return; } catch (Exception e) { System.out.println("3"); } finally ( System.out.println("4"); } System.out.println ("5");

Step by Step Solution

3.38 Rating (151 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

d The program will print 1 4 and 5 in that order The expression 5k will throw an ArithmeticExc... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Programming 8th Questions!