Exam Permalink:
https://www.jobilize.com/java-certification-questions
Question Permalink:
https://www.jobilize.com/how-to-declare-java-generic-collection
Question 80 / 297:  What is the result of compiling and running the following program using jdk 1.5 or higher?
import java.util.ArrayList;

import java.util.List;

interface chewable {}

class Gum implements chewable {}

class Meat implements chewable {}

public class Tester {

public static void main(String[] args) {

List list1 = new ArrayList<chewable>();// line 1

list1.add(new Gum());// line 2

list1.add(new Meat());// line 3

list1.add(new Integer(9));// line 4

System.out.println(list1.size());// line 5

}

}

A  Compilation error at line 1
B  Compilation error at line 4
C  Runtime exception thrown at line 1
D  Runtime exception thrown at line 4
E  3
<< First < Previous Next > Last >>
Exam Home Page
https://www.jobilize.com/java-certification-questions

Oracle Certified Professional Java Programmer

Author:

Access: Public Instant Grading

Ask
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>