Spaces:
Running
Running
| Write a class SuperException which inherits the Exception class. | |
| Class should have a constructor which receives a message as a string. | |
| Constructor should call the super class constructor and pass the message. | |
| No other functionality is required. | |
| import java.util.Random; | |
| public class Test{ | |
| public static void main(String[] args){ | |
| final Random r = new Random(); | |
| } | |
| } | |
| //ADD | |
| class SuperException extends Exception { | |
| public SuperException(String message) { | |
| super(message); | |
| } | |
| } | |
| Testing class SuperException... | |
| Exception object created with message "Exception thrown!" | |
| Reading message: Exception thrown! | |
| Trying to throw and catch exception... | |
| Caught exception! | |
| Message: Thrown again! | |