File size: 734 Bytes
29a26c5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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!