Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ID:12 SCJP Question of the Day

 
wbrian radley
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


the lack of proper formatting is deliberate.
what is the output?

a. code does not compile

b. code compiles but has run-time exception(s)

c. 21xx = 21
bb

d. 21xx=21

e. xx=21

f. 21=xx
bb

g. bb
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does not compile.
the method "whatthe" does not exist! =P

Bad past and copy detected! =P

 
Prasad Kharkar
Ranch Hand
Posts: 446
1
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what are you saying Hebert?
this compiles fine
whatthe is not a method at all
it is a label

and the code outputs
21xx = 21
bb


see the printf method and format specifiers in java for details

but I am eager to know why %n is used there
I am not able to find it
what is the reason?
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prasad Kharkar wrote:what are you saying Hebert?
this compiles fine
whatthe is not a method at all
it is a label

and the code outputs
21xx = 21
bb


see the printf method and format specifiers in java for details

but I am eager to know why %n is used there
I am not able to find it
what is the reason?


wow. I forgot about labels. My bad. Sorry! :$
 
wbrian radley
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
%n prints a line break; tho' its not on the 1.5 exam.

besides lack of formating and the confusing variables notice the
behaviour with:


versus:


I only noticed the difference between the two through my experiments;
I haven't seen other examples of specifiying fewer columns - only $2 - than there are columns (there are 2).


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic