Java AAT5
Java AAT5
COLLEGE OF ENGINEERING
(Autonomous college under VTU)
Bull Temple Rd, Basavanagudi, Bengaluru, Karnataka
560019 2023-2025
“JAVA PROGRAMMING”
(22MCA2PCJP)
By
Vinod Kumar K M
( USN 1BM23MC116)
R V Raghavendra Rao
(Assistant Professor)
1. Define an exception called "NoMatchException" that is thrown when a
string is not equal to "India". Write a program that uses this exception.
import java.util.Scanner;
class StringChecker {
private String target;
scanner.close();
}
}
Output :
2. Write a program for user defined exception that checks the internal and
external marks; if the internal marks is greater than 40 it raises the
exception "Internal marks is exceed"; if the external marks is greater than
60 it raises the exception and displays the message "The External Marks is
exceed". Create the above exception and use it in your program.
import java.util.Scanner;
class MarksChecker {
private static final int INTERNAL_MAX = 40;
private static final int EXTERNAL_MAX = 60;
scanner.close();
}
}
Output :