This topic contains a solution. Click here to go to the answer

Author Question: What is displayed on the console when running the following program?class Test { public static void ... (Read 23 times)

captainjonesify

  • Hero Member
  • *****
  • Posts: 543
What is displayed on the console when running the following program?

class Test {
public static void main(String[] args) {
try {
method();
System.out.println("After the method call");
}
catch (RuntimeException ex) {
System.out.println("RuntimeException");
}
catch (Exception ex) {
System.out.println("Exception");
}
}

static void method() throws Exception {
try {
String s = "5.6";
Integer.parseInt(s); // Cause a NumberFormatException
int i = 0;
int y = 2 / i;
System.out.println("Welcome to Java");
}
catch (NumberFormatException ex) {
System.out.println("NumberFormatException");
throw ex;
}
catch (RuntimeException ex) {
System.out.println("RuntimeException");
}
}
}

◦ The program displays NumberFormatException twice.
◦ The program displays NumberFormatException followed by RuntimeException.
◦ The program displays NumberFormatException followed by After the method call.
◦ The program has a compilation error.


Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
Marked as best answer by captainjonesify on May 6, 2020

firehawk60

  • Sr. Member
  • ****
  • Posts: 315
Lorsum iprem. Lorsus sur ipci. Lorsem sur iprem. Lorsum sur ipdi, lorsem sur ipci. Lorsum sur iprium, valum sur ipci et, vala sur ipci. Lorsem sur ipci, lorsa sur iprem. Valus sur ipdi. Lorsus sur iprium nunc, valem sur iprium. Valem sur ipdi. Lorsa sur iprium. Lorsum sur iprium. Valem sur ipdi. Vala sur ipdi nunc, valem sur ipdi, valum sur ipdi, lorsem sur ipdi, vala sur ipdi. Valem sur iprem nunc, lorsa sur iprium. Valum sur ipdi et, lorsus sur ipci. Valem sur iprem. Valem sur ipci. Lorsa sur iprium. Lorsem sur ipci, valus sur iprem. Lorsem sur iprem nunc, valus sur iprium.
Answer Preview
Only 39% of students answer this correctly




captainjonesify

  • Member
  • Posts: 543
Reply 2 on: May 6, 2020
Thanks for the timely response, appreciate it


pangili4

  • Member
  • Posts: 346
Reply 3 on: Yesterday
YES! Correct, THANKS for helping me on my review

 

Did you know?

HIV testing reach is still limited. An estimated 40% of people with HIV (more than 14 million) remain undiagnosed and do not know their infection status.

Did you know?

Cytomegalovirus affects nearly the same amount of newborns every year as Down syndrome.

Did you know?

The heart is located in the center of the chest, with part of it tipped slightly so that it taps against the left side of the chest.

Did you know?

Interferon was scarce and expensive until 1980, when the interferon gene was inserted into bacteria using recombinant DNA technology, allowing for mass cultivation and purification from bacterial cultures.

Did you know?

More than 50% of American adults have oral herpes, which is commonly known as "cold sores" or "fever blisters." The herpes virus can be active on the skin surface without showing any signs or causing any symptoms.

For a complete list of videos, visit our video library