Q. What will be the output of the following Java program?

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);
        }
        catch(ArithmeticException e) 
        {
      System.out.print("0");         
        } 
        System.out.print(sum);
    }
}
  • (A) 0
  • (B) 05
  • (C) Compilation Error
  • (D) Runtime Error
πŸ’¬ Discuss
βœ… Correct Answer: (C) Compilation Error

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
171
Total Visits
πŸ“½οΈ
2 y ago
Published
πŸŽ–οΈ
Ravi Shankar
Publisher
πŸ“ˆ
80%
Success Rate