Menu
Question Index
...

What will be the output of the following program?

public class GenericConstructorsDemo {
    public static void main(String args[])
    {
        Gen obj = new Gen(100);
        obj.print();
    }
}
class Gen
{
    private double value;
    <T extends Number> Gen(T value)
    {
        this.value = value;
    }
    void print()
    {
        System.out.println(value);
    }
}


100.0
Some other output
Compilation Error
Runtime Error

Doubts

Problems

Topic: Java Generics In Methods And Constructors

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App