About Question com.enthuware.ets.scjp.v6.2.268 : enthuware.ocpjp.v17.2.3238 :

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

Moderator: admin

Post Reply
ssack2014
Posts: 3
Joined: Wed Aug 13, 2014 5:35 pm
Contact:

About Question com.enthuware.ets.scjp.v6.2.268 : enthuware.ocpjp.v17.2.3238 :

Post by ssack2014 »

ch is never initialized. How can 'x = ( ba[ch] = b );' compile? does an uninitialized character default to '0'?

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

Re: About Question com.enthuware.ets.scjp.v6.2.268 :

Post by admin »

static and instance variables are always initialized to their default values if you don't initialize them explicitly.
Local variables aka automatic variables (i.e. variables declared in a method) must be initialized explicitly before using them.
If you like our products and services, please help us by posting your review here.

soncrash
Posts: 8
Joined: Sat Aug 27, 2016 2:51 pm
Contact:

Re: About Question com.enthuware.ets.scjp.v6.2.268 :

Post by soncrash »

I thought it will not compile, because default value for character primitive is \u0000, so we would have something like that ba[\u0000]

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

Re: About Question com.enthuware.ets.scjp.v6.2.268 : enthuware.ocpjp.v17.2.3238 :

Post by admin »

Every character is actually just an integer value. So, \u0000 is just an integer value 0. So b[ch] is b[0] if ch is '\u0000'.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 37 guests