Type Match - Java Quiz Question


What will be the output of the following program?

public class GenericsDemo {
    public static void main(String[] args) {
        A b = new A(20);
        int sum = 10;
        sum += b.ob;
        System.out.println("Sum = " + sum);
    }
}
class A<T> {
    T ob;
    public A(T ob) {
        this.ob = ob;
    }
    public void print(T ob) {
        System.out.println("Obj = " + ob);
    }
}


A
Obj = 20
Sum = 30
B
Obj = 10
Sum = 10
C
Obj = 10
Sum = 30
D
Compilation Error or Runtime Error