Menu
Question Index
...

What will be the output of the following program?

public class BoundedTypeDemo4 {
    
    public static void main(String args[])
    {
        BoundedType4<Wishes> obj = new BoundedType4<Wishes>(new Wishes());
        obj.print();
    }
}
class BoundedType4 <T extends Hello & Hi>
{
    T obj;
    BoundedType4(T obj)
    {
        this.obj = obj;
    }
    void print()
    {
        obj.sayHello();
        obj.print();
    }
}
class Wishes extends Hello implements Hi
{
    public void print() {
        System.out.print("Hi");
    }
}
interface Hi
{
    void print();
}

class Hello
{
    void sayHello()
    {
        System.out.print("Hello   ");
    }
}


Hi
Hello
Hello   Hi
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