Generics Lower Bounded Wildcard - Java Quiz Question


What will be the output of the following program?

public class GenericsLowerBoundedWildCardDemo1 {
    public static void main(String args[]) {
        PrintClassNameHelper<Rectangle> rectangleClass = new PrintClassNameHelper<Rectangle>(new Rectangle());
        print(rectangleClass);
    }
    
    static void print(PrintClassNameHelper<? super Rectangle> printName) {
        printName.print();
    }
}
class Shape {
    void printName() {
        System.out.println("This is shape class");
    }
}

class Rectangle extends Shape {
    void printName() {
        System.out.println("This is Rectangle class");
    }
}
class Square extends Rectangle {
    void printName() {
        System.out.println("This is Square class");
    }
}
class PrintClassNameHelper<T extends Shape> {
    T shape;
    PrintClassNameHelper(T shape) {
        this.shape = shape;
    }
    void print() {
        shape.printName();
    }
}


A
This is shape class
B
This is Rectangle class
C
This is Square class
D
Compilation Error
E
Runtime Error