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

Code:
class exception_handling 
{
    public static void main(String args[]) 
    {
        try 
        {
            int a = args.length;
            int b = 10 / a;
            System.out.print(a);
        }
        catch (ArithmeticException e) 
        {
                System.out.println("1");
        }
    }
}

Note : Execution command line : $ java exception_handling
  • (A) 0
  • (B) 1
  • (C) Compilation Error
  • (D) Runtime Error
πŸ’¬ Discuss
βœ… Correct Answer: (B) 1

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
129
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Vijay Sangwan
Publisher
πŸ“ˆ
89%
Success Rate