About Question enthuware.ocpjp.v11.2.3396 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
alfredo.zuloaga
Posts: 10
Joined: Fri Nov 18, 2016 5:48 pm
Contact:

About Question enthuware.ocpjp.v11.2.3396 :

Post by alfredo.zuloaga »

I have a question., Does TYPE_USE can be applied like
var str = (@NonNull String) "";
and also like
@NonNull String str = "";

?

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

Re: About Question enthuware.ocpjp.v11.2.3396 :

Post by admin »

>var str = (@NonNull String) "";
No.
>@NonNull String str = "";
Yes.

But I suggest you to actually try it out by writing a simple test program.
If you like our products and services, please help us by posting your review here.

61d14837
Posts: 13
Joined: Tue Jul 21, 2020 1:39 pm
Contact:

Re: About Question enthuware.ocpjp.v11.2.3396 :

Post by 61d14837 »

Option 6, explanation says that this is valid
Function<Integer, String> f = ( @NonNull var val ) -> Integer.toHexString(val);
but that doesn't work unless @Target is updated to include ElementType.PARAMETER. This question instead uses ElementType.TYPE_PARAMETER which can be used on parameterized types, generic declarations

In response to the original poster, these both compile

Code: Select all

var str = (@NonNull String) "";
@NonNull String str2 = "";

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests