What will be the output of the following Java code?class exception_handling {public static void main(String args[]) {try {int i, sum;sum = 10;for (i = -1; i < 3 ;++i) {sum = (sum / i);System.out.print(i);}}catch(ArithmeticException e) { System.out.print("0");}}}

🎲 Try a Random Question  |  Total Questions in Quiz: 61  |  🧠 Study this quiz with Flashcards
This question is part of a full practice quiz:
Java Basics Practice Test: Exception Handling — practice the complete quiz, review flashcards, or try a random question.

Quiz on basics of exception handling, exception types like throw, throws and nested try. Java exception handling is a mechanism for handling and responding to runtime errors. Exceptions are events that occur during the execution of a program that disrupt the normal flow of the program. Exception handling allows developers to detect and handle these errors in a controlled manner, preventing the program from crashing.   There are two main types of exceptions in Java: checked exceptions and unchecked exceptions. Checked exceptions are exceptions that must be explicitly handled by the... Show more

What will be the output of the following Java code?<br>class exception_handling <br>{<br>public static void main(String args[]) <br>{<br>try <br>{<br>int i, sum;<br>sum = 10;<br>for (i = -1; i < 3 ;++i) <br>{<br>sum = (sum / i);<br>System.out.print(i);<br>}<br>}<br>catch(ArithmeticException e) <br>{ <br>System.out.print("0");<br>}<br>}<br>}