Menu
Question Index
...

What will be the output of the following program?

public class MarksValidation {
    public static void main(String[] args) throws Exception {
        int marks = 102;
        if (marks < 100) {
            System.out.println("You marks are Valid");
        } else {
            try {
                throw new MyException("You marks are not Valid");
            } catch (MyException e) {
                System.out.println(e.getMessage());
            }
        }
    }
}
class MyException extends Exception {
    public MyException(String string) {
        super(string);
    }
}


You data are Valid
You marks are not Valid
Compilation Error
Runtime Error

Doubts

Problems

Topic: User Defined Exception In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App