26 lines
		
	
	
	
		
			733 B
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
	
		
			733 B
		
	
	
	
		
			Java
		
	
	
	
	
	
class Task {
 | 
						|
    void executeTask() {
 | 
						|
        System.out.println("Task is being executed");
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
class NonNumericTypeException extends Exception {
 | 
						|
    NonNumericTypeException(String msg) {
 | 
						|
        super(msg);
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
class SumTask<T extends Number> extends Task {
 | 
						|
    synchronized T sum(T a, T b) throws NonNumericTypeException {
 | 
						|
        if (a == null || b == null) throw new NonNumericTypeException("Non-numeric type");
 | 
						|
        return (T) Double.valueOf(a.doubleValue() + b.doubleValue());
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
public class Main {
 | 
						|
    public static void main(String[] args) throws NonNumericTypeException {
 | 
						|
        SumTask<Double> task = new SumTask<>();
 | 
						|
        task.executeTask();
 | 
						|
        System.out.println(task.sum(3.0, 4.0));
 | 
						|
    }
 | 
						|
}
 |