aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes  	 ID:12 SCJP Question of the Day Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark " 	 ID:12 SCJP Question of the Day" Watch " 	 ID:12 SCJP Question of the Day" New topic
Author

ID:12 SCJP Question of the Day

wbrian radley
Greenhorn

Joined: Apr 03, 2008
Posts: 22


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

Joined: Jul 14, 2010
Posts: 754

does not compile.
the method "whatthe" does not exist! =P

Bad past and copy detected! =P



[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 446
    
    1

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?

SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

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

Joined: Apr 03, 2008
Posts: 22
%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).


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ID:12 SCJP Question of the Day