Generics Upper Bounded Wildcard2874 - Java Quiz Question


What will be the output of the following program?

public class GenericsWildCardsDemo {
    public static void main(String args[])
    {
        Variables<Integer> obj = new Variables<Integer>(5, 8);
        print(obj);
    }
    public static void print(Variables<T extends Number> var)
    {
        System.out.println(var.getAddition());
    }
}
class Variables<T extends Number>
{
    T x;
    T y;
    Double sum = 0.0;
    public Variables(T x, T y) {
        this.x = x;
        this.y = y;
    }
    public Double getAddition()
    {
        sum+= x.doubleValue() + y.doubleValue();
        return sum;
    }
}


A
0.0
B
13.0
C
Compilation Error
D
Runtime Error