Which line in the code below will generate a compilation error?

01. public class Q11 {
02.    public static void main(String[] args) {
03.        List<? super Integer> one = new ArrayList<Integer>();
04.        addsome((List<? super Number>) one);
05.    }
06.    private static void addsome (List<? super Number> l){
07.        l.add(1);
08.        Number num = 1;
09.        l.add(num);
10.        Object ob = 1;
11.        l.add(ob);
12.        l.add(null);         
13.     }    
14. }
Explanation
The line

addsome (List l)
means the input list can only accept objects whose class or superclass is Number. Accordingly, an object of type Object will not be accepted.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback