About printing of default values

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

Moderator: admin

Post Reply
Rinkesh
Posts: 35
Joined: Sat Nov 25, 2017 4:13 pm
Contact:

About printing of default values

Post by Rinkesh »

Paul,I gave my exam today and got 75% which is good considering my first oracle certification exam.I had a question in exam which I wanna ask.I am asking here because I don't know where to ask and this is the place where you gave me your last reply.

There was a question which was printing char,boolean and float default values and there were 2 confusing options:-

a. char = 0 b. char =
boolean = false boolean = false
float = 0.0f float = 0.0

I marked a. because I remember you said that char is nothing but an unsigned integer and also because float doesn't have f with it in the second option.I have classes notes which says b. is the correct answer.So,Did I mark the right option or Wrong option?

Sorry for asking here but I am really passionate and you can delete it or I will delete it after my doubt is cleared.
Thank you in Advance.

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

Re: About printing of default values

Post by admin »

Sorry, the correct answer should be b :(

Yes, char is an integral type but it is interpreted as a character. So while printing 0, the println method will using try to print the character associated with the number 0. This will print a blank.

An f is needed only while defining a float value to distinguish it from a double. But while printing, it will use Float.toString(f) to get a String representation of float, which is just 0.0.

Although question Q 2.1378 shows how a float is printed, we will add a question that cover this point more thoroughly.

thank you for your feedback!

Rinkesh
Posts: 35
Joined: Sat Nov 25, 2017 4:13 pm
Contact:

Re: About printing of default values

Post by Rinkesh »

My Pleasure!

Post Reply

Who is online

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