Page 4 of 55 FirstFirst ... 234561454 ... LastLast
Results 61 to 80 of 1093

Thread: Quiz Time

  1. #61
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  2. #62
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by rjuyal View Post
    BTW, what's the logic behing 2.3

    i will post the answer with reason after this :)
    I didn't get you on this pal.

  3. #63
    rjuyal's Avatar
    rjuyal is offline Senior Member
    Join Date
    Mar 2008
    Location
    Delhi, India
    Posts
    194
    Rep Power
    7

    Default

    Java Code:
    Value will be 2
    sanjeev please post the exact print

    like Eranga did

    Java Code:
    Value is - 2.3

    You want the answer ?? :rolleyes:
    i am the future

  4. #64
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    I'm worried on my last post Rakesh. What you mean the logic of 2.3, any special reason.

    May be your answer give the solution.:)

  5. #65
    sanjeevtarar's Avatar
    sanjeevtarar is offline Senior Member
    Join Date
    Apr 2008
    Location
    Jaipur(India)
    Posts
    318
    Rep Power
    7

    Default

    Java Code:
    Value is - 2
    sanjeev,संजीव

  6. #66
    rjuyal's Avatar
    rjuyal is offline Senior Member
    Join Date
    Mar 2008
    Location
    Delhi, India
    Posts
    194
    Rep Power
    7

    Default

    answer is

    Java Code:
    Value is: - 2.0
    Reason being

    a>5 evaluates to false so the answer should be

    Java Code:
    Value is: - 2
    but,

    2.3 ( double) and 2(int) are of different types. So the type chosen by Ternary will be by rule of promotion, hence 2 will be converted to 2.0

    and the answer is


    Java Code:
    Value is: - 2.0
    i am the future

  7. #67
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    it should be 2.... i think....

    5 never can be called greater than 5......
    freedom exists in the world of ideas

  8. #68
    sanjeevtarar's Avatar
    sanjeevtarar is offline Senior Member
    Join Date
    Apr 2008
    Location
    Jaipur(India)
    Posts
    318
    Rep Power
    7

    Default

    Quote Originally Posted by Eranga View Post
    I'm worried on my last post Rakesh. What you mean the logic of 2.3, any special reason.

    May be your answer give the solution.:)
    Actually he is asking that, How you got this ans, What is your logic to calculate the 2.3.
    sanjeev,संजीव

  9. #69
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Ah, a nice point. ternary operator evaluates integer values. :)

    Anyway, I have to go now my friends. Keep going, I'll back to here tomorrow. Nice work pal. Thanks for all of you. Keep going this, rather starting a new one. Doesn't matter how it long. I'll manage i'll manage it for all of you.

    Good luck,
    Eranga:):)

  10. #70
    rjuyal's Avatar
    rjuyal is offline Senior Member
    Join Date
    Mar 2008
    Location
    Delhi, India
    Posts
    194
    Rep Power
    7

    Wink Banana is still with me

    answered in #66

    Next question Please
    i am the future

  11. #71
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Java Code:
    public class test{
           public static void main(String quiz[]){
                  String t1 = "23";
                  String t2 = "11.5 * 2";
                  if(Double.valueOf(t1)==Double.valueOf(t2))
                         System.out.print("true");
                  else
                         System.out.print("absolutely impossible");
           }
    }
    What can you guess about the code above?
    freedom exists in the world of ideas

  12. #72
    rjuyal's Avatar
    rjuyal is offline Senior Member
    Join Date
    Mar 2008
    Location
    Delhi, India
    Posts
    194
    Rep Power
    7

    Default

    parse exception :confused:
    i am the future

  13. #73
    sanjeevtarar's Avatar
    sanjeevtarar is offline Senior Member
    Join Date
    Apr 2008
    Location
    Jaipur(India)
    Posts
    318
    Rep Power
    7

    Default

    Number Format Exception...
    sanjeev,संजीव

  14. #74
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Yah... NumberFormatException.....

    It can never be treat as a pure Floating Decimal values.
    ...11.5 * 2...
    freedom exists in the world of ideas

  15. #75
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Without attempting to compile the code below,

    What should be the output?

    Java Code:
    public class test {
    
        public static void main(String quiz[]) {
    
            System.out.print("H" + "a");
    
            System.out.print('H' + 'a');
    
        }
    
    }
    freedom exists in the world of ideas

  16. #76
    sanjeevtarar's Avatar
    sanjeevtarar is offline Senior Member
    Join Date
    Apr 2008
    Location
    Jaipur(India)
    Posts
    318
    Rep Power
    7

    Default

    Quote Originally Posted by sukatoa View Post
    Without attempting to compile the code below,

    What should be the output?

    Java Code:
    public class test {
    
        public static void main(String quiz[]) {
    
            System.out.print("H" + "a");
    
            System.out.print('H' + 'a');
    
        }
    
    }

    Will not compile
    sanjeev,संजीव

  17. #77
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    Actually it compiles.... it has an output. guess what?
    freedom exists in the world of ideas

  18. #78
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    at first attempt of printing "Ha", allowable... obviously,

    The problem is on the second attempt....
    H and a are now char literals... There decimal value will be printed.. instead of concatenating like the previous one, it now adds their decimal representation that leads to 169

    eg. Ha169.

    ref, ascii chart.

    Just sharing,
    freedom exists in the world of ideas

  19. #79
    rjuyal's Avatar
    rjuyal is offline Senior Member
    Join Date
    Mar 2008
    Location
    Delhi, India
    Posts
    194
    Rep Power
    7

    Default

    o man! i could have answered it :(

    y i got the mail notification after half an hour :eek:
    i am the future

  20. #80
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    maybe because you have subscribed a specific thread.

    next quiz please... i hope i can catch one....
    freedom exists in the world of ideas

Page 4 of 55 FirstFirst ... 234561454 ... LastLast

Similar Threads

  1. Hello, first time here.
    By ludragon in forum Introductions
    Replies: 2
    Last Post: 01-03-2008, 05:03 AM
  2. Help pls with a quiz
    By saytri in forum New To Java
    Replies: 3
    Last Post: 12-23-2007, 06:09 AM
  3. Time method
    By carderne in forum New To Java
    Replies: 5
    Last Post: 11-05-2007, 09:34 AM
  4. DataObject with the time given by me
    By garinapavan in forum New To Java
    Replies: 2
    Last Post: 08-07-2007, 06:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •