Menu
Question Index
...

At what line will there be a compilation error?

public class Generics {
    public static void main(String[] args) {
        B b = new B(); /* LINE A */
        C c = b.process(new C()); /* LINE B */
        B<C> b2 = new B<C>(); /* LINE C */
        C c2 = b2.process(new C()); /* LINE D */
    }
}
interface A {
    int count();
    void show();
}
class B<T extends A> {
    T process(T t) {
        t.count();
        t.show();
        return t;
    }
}
class C implements A {
    public int count() { return 25; }
    public void show() { System.out.print("Class C"); }
}


LINE A
LINE B
LINE C
LINE D
Compilation Error at some other line
No Compilation Errors

Doubts

Problems

Topic: Java Generics

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App