File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes mock exam confusion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "mock exam confusion" Watch "mock exam confusion" New topic
Author

mock exam confusion

Rachel Glenn
Ranch Hand

Joined: Oct 24, 2012
Posts: 95
The sierra/bates mock exam says this WILL compile:




but I know this statement does NOT compile:



Can someone explain why? I thought the rules for both format() and print() were the same...
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2853
    
  11

I think you mean format() and printf() behave the same. Both print() and println() in the PrintStream class (which is what System.out is) have a different interface. In particular, they only take a single parameter, so when you try to call System.out.print() with two parameters, the compiler complains.
Rachel Glenn
Ranch Hand

Joined: Oct 24, 2012
Posts: 95
Greg Charles wrote:I think you mean format() and printf() behave the same. Both print() and println() in the PrintStream class (which is what System.out is) have a different interface. In particular, they only take a single parameter, so when you try to call System.out.print() with two parameters, the compiler complains.


oops...

Sooo.....

-print() and println() each take a single argument (no formatting characters allowed!)
-format() takes multiple arguments and returns a string
-printf() formats AND prints...

right?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: mock exam confusion