Menu
Question Index
...

What will be the output of the following program?

public class GenericsErasureDemo {
    public static void main(String args[])
    {
        GenericsErasure<String> stringObject = new GenericsErasure<String>("Hello");
        System.out.println(stringObject.getClass().getName());
        stringObject.showType();
    }
}
class GenericsErasure<T> {
    T obj;
    GenericsErasure(T obj)
    {
        this.obj = obj;
    }
    void showType()
    {
        System.out.println(obj.getClass().getName());
    }
}


GenericsErasure
java.lang.String
java.lang.String
GenericsErasure
java.lang.String
java.lang.String
GenericsErasure
GenericsErasure
Compilation Error

Doubts

Problems

Topic: Java Type Erasure

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App