About Question enthuware.ocpjp.v8.2.1824 :

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
fodpeter@gmail.com
Posts: 1
Joined: Sat Jul 16, 2016 8:17 am
Contact:

About Question enthuware.ocpjp.v8.2.1824 :

Post by fodpeter@gmail.com »

Hi

I think the explanation of "1Z0-809, Test 2, question 54" contains a typo: the <X> declaration is mandatory before the return type.

Peter
public static <X> PlaceHolder<X, X> getDuplicateHolder(X x){
    return new PlaceHolder<>(x, x); //use diamond operator because we already know that X is a generic type.
}

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

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

Post by admin »

You are right. Fixed.
thank you for your feedback!
Paul.
If you like our products and services, please help us by posting your review here.

vlive07@gmail.com
Posts: 4
Joined: Fri Sep 30, 2016 4:44 am
Contact:

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

Post by vlive07@gmail.com »

return new PlaceHolder<X, X>(x, x);

i don't understands this . as per i know you cant instantiate generic. Kindly give example :thumbup:

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

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

Post by admin »

I am not sure what you mean by, "You can't instantiate generic".
Here is an example from official Java tutorial: https://docs.oracle.com/javase/tutorial ... types.html

Code: Select all

Pair<String, Integer> p1 = new OrderedPair<String, Integer>("Even", 8);
Pair<String, String>  p2 = new OrderedPair<String, String>("hello", "world");
HTH,
Paul.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests