Menu
Question Index
...

What will be the output of the following program?

public class GenericsErasureDemo {
    public static void main(String args[])
    {
        GenericsErasure<Float> floatObject = new GenericsErasure<Float>(12.0F);
        System.out.println(floatObject.getClass().getName());
        floatObject.showType();
    }
}
class GenericsErasure<T> {
    T obj;
    GenericsErasure(T obj)
    {
        this.obj = obj;
    }
    void showType()
    {
        System.out.print(obj.getClass().getName());
    }
}


GenericsErasure
java.lang.Float
java.lang.Float
GenericsErasure
java.lang.Float
java.lang.Float
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