From d34ea2ca6b9ba7b2eabd71bf5c674c40507c827a Mon Sep 17 00:00:00 2001 From: Rajjit Laishram <93727816+rajjitlai@users.noreply.github.com> Date: Sun, 13 Oct 2024 23:59:06 +0530 Subject: [PATCH] added-java-4 --- Java/Practical/UnderAge.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Java/Practical/UnderAge.java diff --git a/Java/Practical/UnderAge.java b/Java/Practical/UnderAge.java new file mode 100644 index 0000000..f00c1e1 --- /dev/null +++ b/Java/Practical/UnderAge.java @@ -0,0 +1,15 @@ +// File: UnderAge.java +class UnderAge extends Exception { + private int age; + + // Constructor to initialize age + public UnderAge(int age) { + this.age = age; + } + + // Override toString() to display custom message with age value + @Override + public String toString() { + return "Under Age: " + age; + } +} \ No newline at end of file