About Question enthuware.ocpjp.v8.2.1265 :

All the posts and topics that contain only an error report will be moved here after the error is corrected. This is to ensure that when users view a question in ETS Viewer, the "Discuss" button will not indicate the presence of a discussion that adds no value to the question.

Moderators: Site Manager, fjwalraven

Post Reply
javalass
Posts: 54
Joined: Thu Mar 03, 2016 1:26 pm
Contact:

About Question enthuware.ocpjp.v8.2.1265 :

Post by javalass »

Regarding option 2:

Code: Select all

List<String> list = new ArrayList<>(); 
list.add("A"); 
list.addAll(new ArrayList<>());
with the explanation
Java SE 7 supports limited type inference for generic instance creation; you can only use type inference if the parameterized type of the constructor is obvious from the context. In this option, the last line will not compile because list.addAll() method expects Collection<? extends String> and so the compiler cannot infer the generic type for ArrayList.
This only applies to Java 7. In Java 8, the code above compiles and runs fine. Mind you, they do say you should avoid doing it, so I suppose this wouldn't be considered "appropriate use of generics".

javalass
Posts: 54
Joined: Thu Mar 03, 2016 1:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1265 :

Post by javalass »

I just noticed this is a duplicate of viewtopic.php?f=38&t=3562, sorry.

admin
Site Admin
Posts: 10402
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v8.2.1265 :

Post by admin »

Fixed in the upgrade question bank.
thank you for your feedback!

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests