Question 89 / 297:  The following program contains two compilation errors, at what lines?
Choose 2
import java.util.ArrayList;

import java.util.List;

interface Chewable {}

class Meat implements Chewable {}

public class Tester {

public static List<? extends Chewable> printSize(List<? extends Chewable> list) { // Line 10

System.out.println(list.size());

return list;

}

public static void main(String[] args) {

List<? extends Chewable> list1 = new ArrayList<Meat>(); // Line 16

List<Chewable> list2 = new ArrayList<Chewable>(); // Line 17

List<Meat> list3 = new ArrayList<Meat>(); // Line 18

list1 = printSize(list1); // Line 20

list2 = printSize(list2); // Line 21

list3 = printSize(list3); // Line 22

}

}

<< First < Previous Next > Last >>
Explanation:

The return type of printSize() does not match with the types of list2 and list3

Exam Home Page
Ask
Eric Crawford
Start Quiz
David Bourgeois
Start Quiz
Sarah Warren
Start Test
Copy and paste the following HTML code into your website or blog.
<iframe src="https://www.jobilize.com/embed/java-certification-questions" width="600" height="600" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes" style="border:1px solid #CCC; border-width:1px 1px 0; margin-bottom:5px" allowfullscreen webkitallowfullscreen mozallowfullscreen> </iframe>