Menu
Question Index
...

What will be the output of the following program?

public class BoundedTypeDemo3 {
    public static void main(String args[])
    {
        BoundedType3<First> obj1 = new BoundedType3<First>(new Second());
        obj1.print();
    }
}
class BoundedType3<T extends MyName>
{
    T obj;
    BoundedType3(T obj)
    {
        this.obj = obj;
    }
    void print()
    {
        obj.printName();
    }
}
interface MyName
{
    void printName();
}
class First implements MyName
{

    public void printName() {
        System.out.println("Hi... This is First class");
    }
        
}
class Second implements MyName
{
    public void printName() {
        System.out.println("Hi... This is Second class");
    }
}


Hi... This is First class
Hi... This is Second class
Hi... This is First class
Hi... This is Second class
Compilation Error
Runtime Error

Doubts

Problems

Topic: Java Bounded Type - Bounded Type In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App