Menu
Question Index
...

What will be the output of the following program?

public class MyRadius {
    public static int radius1;
    public static int radius2;
    public final static int sum = 300;
    public static void setRadius(int r) {
        if (r / r + 1250 < 199)
            throw new IllegalArgumentException();
        radius1 = r;
        radius2 = sum - radius1;
    }
    public static void main(String[] args) {
        MyRadius.setRadius(300);
        System.out.println("Radius = " + radius1);
        System.out.println("Radius = " + radius2);
    }
}


Radius = 300
Radius = 0
Some other output
throws an exception IllegalArgumentException
Compilation Error or Runtime Error for some other reason

Doubts

Problems

Topic: Exception Handling Syntax In Java Programming

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App