Question: Task 24: RuntimeException Aim: To explore the Subclasses of RuntimeException. Title: Testi, Test2, Test3, Test4 and Tests classes. Summary: be familiar with RuntimeException. Question: What

 Task 24: RuntimeException Aim: To explore the Subclasses of RuntimeException. Title:
Testi, Test2, Test3, Test4 and Tests classes. Summary: be familiar with RuntimeException.
Question: What RuntimeException will the following programs throw, if any? public class

Task 24: RuntimeException Aim: To explore the Subclasses of RuntimeException. Title: Testi, Test2, Test3, Test4 and Tests classes. Summary: be familiar with RuntimeException. Question: What RuntimeException will the following programs throw, if any? public class Test! public static void main(String[] args) : System.out.println(1/0); 3 3 public class Test2 public static void main(String[] args) int[] list = new int[5): System.out.println(list[5]); 1 public class Test public static void main(String[] args) { String s="abe": System.out.println(s.charAu(3) public class Test4 public static void main(String[] args) Objecto new Object(): String d (String): - public class Test: public static void main(String[] args) Objecto null; System.out.println(o.toString()) Task 25: Input MismatchException Aim: Using a loop with Exception. Title: SumClass class. Summary: prompt the program to read a number again. Question: In this task, write a program that prompts the user to read two integers and displays their sum. Your program should prompt the user to read the number again if the input is incorrect (InputMismatchException) Task 26: throws Exception. Aim: To declare exceptions in a method header and to throw exception in a method. Title: Circle, Test classes. Summary: Demonstrates declaring, throwing, and catching exceptions. Question: In this task, defines a class named Circle, as shown below, the setRadius (double new Radius) method throws an Exception if the argument new Radius is negative, this method throws the exception and doesn't catch itself, also write a test Java program that create an object of type Circle then test the setRadius ....) method by asking the user to enter the value of the new radius. Your program should prompt the user to read the new radius again if the input is incorrect. Here is the class Circle: public class Circiel private double radius: public Circle(double radius) this.radius-radius: } public void setRadius(double newRadius) { radius-new Radius ) } ramm Task 27: Defining Custom Exception Class. Aim: To define a Custom Exception. Title: Person, Illegal PersonException and Test classes. Summary: You can define a custom exception class by extending the Exception class. Question: In this task, create a Person class of three attributes name, age, and city. In our program, any person his/her age must be greater than or equal 18. The defined Person class must follow to this rule. To do that, let the constructor throws a custom exception named illegalPersonException object if a person is created with age that violate the rule. Also, write a test Java program that create an object of type Person by asking the user to enter the name, age and city. Your program should prompt the user to read the name, age, and city again if the input is incorrect

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!