Query from Kathy Sierra book

In chapter 6 self test question no 9 :
System.out.format("%s", new Long("123"));
This code is said to be fine and that it will compile without any error.
Here we are creating and object of the Long wraper class and %s is for String. In the previous chapters we studied that Wrapper classes cant be widened among one another.
So can any tell me the concept why this piece of code will compile?

It compiles without error because the first argument is a string.
It also runs without any problem because %s is a very accomodating format specifier - it will simply print the string form of the corresponding argument.import java.util.Date;
public class SFormat {
    public static void main(String args[]) {
        System.out.format("%s%n", new Long("123")); // 123
        System.out.format("%s%n", System.out);     // java.io.PrintStream@9304b1
        System.out.format("%s%n", new Date());     // Fri Jun 01 17:46:14 NZST 2007
}

Similar Messages

  • Doubts from Kathy Sierra Book

    Hi everone
    I am preparing for SJCP5.0 from Seirra and Bates and i have completed the 1st chapter. I have a few queries from the same chapter. Can anyone help me on these quetions?
    1) What is the difference between class variable and instance variable?
    2) is there only 1 currency character ($) and only 1 connecting character(_)?
    3) Is class2. valid name for a class name?

    1.
    Given the following,
    1. interface Base {
    2. boolean m1 ();
    3. byte m2(short s);
    4. }
    Which code fragments will compile? (Choose all that apply.)
    A) interface Base2 implements Base { }
    B) abstract class Class2 extends Base {
    public boolean ml() { return true; } }
    C) abstract class Class2 implements Base { }
    D) abstract class Class2. implements Base {
    public boolean m1() { return (true); } }
    E) class Class2 implements Base {
    boolean m1( ) { return false; }
    byte m2(short s) { return 42; } }
    This is the exact question. Look at option D. According to the question this option should be wrong. However the solution says that option D is correct because it is implemented properly.
    Can you help me on this?

  • Kathy Sierra book for SCWCD 1.4

    Hi,
    Somebody pls give me pdf for Head First Servlets & JSP by Kathy Sierra. I am preparing for the SCWCD 1.4 exam. Please help me with some mock test as well.
    Thanks in advance.
    Nikesh Shah.

    Hi Nikesh,
      I have searched that <b>nowhere i can find this Head First Servlets & JSP by Kathy Sierra</b>.  You can go through this <a href="http://java.sun.com/j2ee/1.4/docs/tutorial/doc/J2EETutorial.pdf">J2EE Tutorial</a>, which will give you detail information for free download.
    Regards,
    Venkatesh. K
    /* P.S: Consider Points if it is useful */

  • Kathy Sierra SCWCD 1.4 book

    Hi,
    Can somebody please give me the book for SCWCD 1.4 i.e. Head First Servlets and JSP by Kathy Sierra . I am preparing for the exam. Also please provide me some Mock test for the same.
    My ID is [email protected].pls help.
    Thanks in advance.
    Nikesh Shah.

    It's not illegal Kajbj.Isn't illegal? Why do you think it isn't illegal to download copyrighted material? Why would it be legal?
    We hv to share our knowledge with others..Sharing knowledge isn't the same as stealing/copying copyrighted material.
    So wht's
    the problem in giving books online...The problem is that it's illegal. Authors usually want to get paid for what they write.
    I know this is
    very important book for SCWCD exam..so the author of
    the book has not given permission to download the
    book.Because he/she wants to earn money. Wouldn't you want to get paid if you write a book?
    New_Kid : pls find the book on the net .Please don't.
    Kaj

  • Problem class important error while executing Query from favorites

    Hi Experts,
    1. I have tried execute the query from favorites it is showing the error message. " Problem class important"
        In the message text: logs showing error message [Attached the message screenshot].
    2. From "Query Designer" Execute [Ctrl+R] gives the error "500 Internal Server Error" [Attached the screenshot]
    3. Able to execute the reports from RRMX.
    No ST22 dumps. Can any one suggest about...how to rectify the errors.
    Thanks in advance...Surya

    Need tyo make sure the problem is with the query/workbook are general issue with all workbooks/query.
    1. Make sure the base query of work book is still executable. RRMX/RSRT.
    2. Execute the work book in Bex/Excel and look for definition of workbook; there might be some thing in the workbook referencing other than base query.
    3. If other workbook are also not working? need to check if other users have same issue.?
    Hope this will help to narrow the problem.
    Gopi

  • I desperately to uninstall adobe reader from my Mac book air. I sent adobe reader to trash and afterwards look for internet plugs in in library but the folder is empty. Can anybody help me?

    I desperately need to uninstall adobe reader from my Mac book air. I sent adobe reader to trash and afterwards look for internet plugs in  library but this folder is empty in my library. Can anybody help me?

    I looked for plugs in in my library but the folder internet plugs in is empty

  • Contact name not showing in call/sms log even when I call/sms from my address book.

    Two things have changed on my phone recently.
    1. I ran the latest update 4.3.2
    2. My phone was not showing all the contacts in my address book that is in my Mobile Me account. Mobile me had 166 contacts. The iPhone 4 had 136. I I unchecked the syncing of my contacts on my phone. This removed all the contacts from my phone. Then I check the syncing options again. All 166 appeared on the phone.
    I'm not sure which of the two caused the issue but now anytime someone who calls their name does not appear on the display or log, just their number. I can even call people from my address book and the display shows that I am calling them with their name and photo on display. However, in the call log the name does not show just their number.  This applies for text messages. I send a message directly from within the contact card in the address book and in my text log it shows only the number and not the name.
    I've turned the phone off and on a couple of times.
    I would appreciate any advice.
    Cheers

    Thanks iraghib,
    In the end I reset my phone to factory settings. I created a back up of my address book and ical. Reset the phone and did a sync again. This fixed it all. I didn't need to use the backups but is was nice to know they were there. I felt entering the various passwords for all my installed apps was a much better deal than adding the international area code to the 166 contacts I have in my address book.
    Good luck. And thanks for the post.

  • Hi I've a big problem with adobe acrobat reader XI pro and I hope you can help me. The problem is; when I past copied text from some pdf books (not all of them) it past symbols only! wherever I past it! and even if I coped that text from another pdf reade

    Hi
    I've a big problem with adobe acrobat reader XI pro and I hope you can help me.
    The problem is; when I past copied text from some pdf books (not all of them) it past symbols only! wherever I past it! and even if I coped that text from another pdf reader (adobe pdf reader, internet browsers, ...etc.).
    This problem started to happen since yesterday when I installed adobe acrobat reader XI pro to try it before I buy it, and before that when I was using the free adobe pdf reader I was totally able to copy any text from any pdf and past it anywhere with nothing wrong.
    What can I do?
    thank you a lot.

    There is no product called Adobe Acrobat Reader Pro. There is
    - Adobe Acrobat Pro ($$)
    - Adobe Reader (free)
    Which do you have? And are you a programmer?

  • Is it possible to open a query from sap menu favorite to excel?

    Hi all
    I have added a query in favorite . From the favorite in sap menu , i want to open the query in excel.
    Is is possible?
    Currently the query open in web.
    Please revert back if you have any idea
    Thanks
    ajay

    Hi Daya Sagar,
    You said the query saved in favorite from query designer will open in browser and the one saved from analyzer will open in bex excel. But it does not work for me. It saves as web icon and both query is opening in browser.
    Hi All,
    The different story for me is I have problem of opening the web browser by running a query from favorite or user menu because in the url I have different Client. Is there any way to fix this url problem. Any one in this thread can help me on this issue and will be awarded. Thanks.
    Raj

  • I am using Mail with OS 10.9.1...I used to be able to drag and drop contact addresses from my address book to an e-mail header.  Now I have to type all the names and can't drag and drop.  Is there a setting for this?  Thanks!

    I am using Mail with OS 10.9.1.  I used to be able drag and drop names from my address book into the address header, but can no longer do that.  I now have to type each name in.  Does anyone know if there is a setting for this or is it a feature of the updated software?  Thanks for any info!

    Yes, that appears how Mavericks works right now. However, you can open the Address Panel, select all your contacts, then click the To (or CC, or Bcc) buttons to move the selection to the address field.
    If it is not already in the Toolbar, right-click on the Toolbar and select Customize Toolbar…
    Then, drag the address panel up to wherever you want it.
    You may also want to add it to the New Message window in the same way.

  • See sql query from crystal report without crystal report

    see sql query from crystal report without crystal report 

    Hi,
    Depends on datasource type but you could have a look at ODBC trace or if you have access to the SQL Server you could use profiler to monitor the session.
    Regards,
    Craig
    And this will only be of use if you know which Server/Insstance/Database the Report is connecting to...
    Please click "Mark As Answer" if my post helped. Tony C.

  • How can I delete files from My Mac Book Pro safely to create more space?

    Hi,
    I need to delete files from my Mac Book Pro and I am not sure how to do it safely without affecting my computers drivers or operations.
    In my Finder - All Files Section there are certain files in the Preview, marked as "PNG Image", Window Image, GIF image, XLM. when I look at them they seem scripted or sections of an image. How do I know which files are safe to remove
    I seem to find a lot of duplicated files - is there a way of stopping this from happening?
    Thanks from a little frustrated Mac Book user.

    Welcome to Apple Support Communities
    Transfer them to an external disk formatted in "MS-DOS (FAT)" with Disk Utility > http://pondini.org/OSX/DU1.html
    If you have the pictures in iPhoto, choose them with the Command key, go to File menu (on the menu bar) > Export, and copy them to the external disk. Then, connect your external disk to the PC and move them.
    If you have the pictures in Finder, steps are the same, but in this case, you will have to drag the pictures you chose to the external disk that you can find in the Finder sidebar, under "Devices"

  • How can I do to transfer all iTunes library from my Mac book Pro to Time capsule without to lost the alphabetic sequence of songs

    How can I do to transfer all iTunes library from my Mac book Pro to Time capsule without to lost the alphabetic sequence of songs & artists? What is the correct way to transfer my 3000 songs to Time capsule, to free the memory of my Mac? Thanks a lot. Carlo Molinari (Rome - Italy)

    How can I do to transfer all iTunes library from my Mac book Pro to Time capsule without to lost the alphabetic sequence of songs & artists? What is the correct way to transfer my 3000 songs to Time capsule, to free the memory of my Mac?
    The following are the basic steps to transfer your iTunes Media folder from your MacBook Pro to the Time Capsule (TC). Note: You will leave the iTunes Library, and its associated files, on the MacBook Pro as you will only be moving the media files.
    Be sure to shutdown iTunes before starting.
    Next, move the "iTunes Music" folder, located in ~/Music/iTunes/, to wherever you want on your TC's internal hard drive. Remember to leave the Album Artwork folder, as well as the three individual library files where they are on the MacBook Pro.
    Wait a while. If you have a large library, this will take a bit of time.
    Once the iTunes Media folder has been transferred, open iTunes. Note: It will still be looking at your local iTunes Library on the MBP. As such it will think that the iTunes Media folder is still on the MBP as well. However, we just relocated it to the TC. If you attempt to select any song, you will get an error that the song is "missing." Not to worry, we will correct this in the next step.
    We need to tell iTunes the media has moved to the TC's internal HDD. To change where iTunes "looks" for the media, open iTunes and go to the Advanced > General tab and use the "Change..." button to tell it where your new "iTunes Music" library is located.
    Once this is done iTunes will likely pop up a progress window telling you that it's re-analyzing your library. Let it complete this step.
    As a final check to make sure everything when as planned, click on any library file from within iTunes and press cmd + i (or View > Get Info). At the bottom of the Summary tab in that window is a "Where:" section that tells you the actual file path to that piece of media; be sure that path begins with the name of your TC's drive, and not "Macintosh HD."

  • Moving pages from one iphoto book to another iphoto book

    I have hit the 100 page maximum in a book I am making of recent travels. I'd like to copy and paste pages from this book into a new book so that I have volumes I and II. Is there a way to move pages from one book to another without simply re-creating them? Thanks!

    Only thing I can think of is you can duplicate the whole book and then delete the pages you don't want from the new book. I'm pretty sure there's no way to copy pages from one book to another existing book.

  • How do you select multiple emails from the contacts book.

    Using 10.8.4. I would like to use mail and select multiple email address' from the contacts book to send the same message to multiple persons. I thought I used to be able to select more than one at a time from my contacts book. Am I crazy or did they change the way it works from the previous version of software.
    Or, could you go to the contacts book and email from there. Either way it seems like it was easy to do and now I have to select one at a time and keep going back to the contacts/address book for another name.

    Hi shelereric,
    Once you open a new message, you should be able to just start typing the first letters of the contact's name, and Mail should give you a dropdown to select from:
    So, you should not have to go back and forth between your contacts and mail....anyone in your address book should show up on the dropdown as well as anyone you have received emails from or sent emails to even if they are not in your contacts....
    Is that not what is happening for you? Are you using the Mail app on the Mac?
    Cheers,
    GB

Maybe you are looking for