Page 52 of 55 FirstFirst ... 2425051525354 ... LastLast
Results 1,021 to 1,040 of 1093

Thread: Quiz Time

  1. #1021
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,926
    Rep Power
    19

  2. #1022
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,431
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Cbani View Post
    answer is correct; but any proper justification?
    I gave the reason in my previous reply; what more do you want to read?

    kind regards,

    Jos

  3. #1023
    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 Cbani View Post
    where z Eranga? Busy with no doors and no windows room :)
    Seems our guys already comment on this. :(

  4. #1024
    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 JosAH View Post
    I beg to differ: a synchronized method synchronizes on the object for which it is a member; different objects synchronize on different 'this's so the printing will happen in no particular order.
    One execution after the other, is it? I'm not exactly clear what you mean by different objects synchronize on different 'this's so the printing will happen in no particular order

  5. #1025
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,431
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Eranga View Post
    One execution after the other, is it?
    No, they both execute simulaneously because both those methods synchronize on the objects themselves, not on one object. IOW a synchronized method is the same as:

    Java Code:
    public void method() {
       synchronized (this) {
          // ...
       }
    }
    kind regards,

    Jos

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

  7. #1027
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    :D You've use additional digit, 5, at last.
    Not exactly... I've just replaced it ;)

    And ones more :)

    5+55>50+5
    5+5<55+50

    Really odd way. that would be more pleased to use math rules instead )

  8. #1028
    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

    :D Actually that's not that much difficult lol. Here is the third possibility we have.

    5 + 5 + 5 = 550
    change into, by using a single line,

    5 4 5 + 5 = 550
    Change the first + sign into number for just adding a line.

  9. #1029
    Cbani is offline Member
    Join Date
    Jan 2010
    Posts
    90
    Rep Power
    0

    Default

    That's true. That's what I thought. So the result should be the first one.
    what is the first one?
    Last edited by Cbani; 04-21-2010 at 07:36 AM.

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

  11. #1031
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    :D Actually that's not that much difficult lol. Here is the third possibility we have.



    change into, by using a single line,



    Change the first + sign into number for just adding a line.
    Oop... but I thought I cannot del + characterss at all :D

  12. #1032
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Lightbulb

    So then it is true as

    5+505<550
    and
    5+5+0==550
    :rolleyes:

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

  14. #1034
    Cbani is offline Member
    Join Date
    Jan 2010
    Posts
    90
    Rep Power
    0

    Default

    here is one more...

    Java Code:
    public int getCount() {
    		int i = 0;
    		System.out.println(Thread.currentThread().getName());
    		while(true) {
    			     System.out.println("hello!!!");
    			}
    	}
    getCount method signature says that it returns an integer value; but there is no return statement in the method.

    Question is would it give a compile time error?
    Last edited by Cbani; 08-10-2010 at 10:15 AM.

  15. #1035
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,431
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Cbani View Post
    here is one more...

    Java Code:
    public int getCount() {
    		int i = count;
    		count++;
    		System.out.println(Thread.currentThread().getName());
    		while(true) {
    			     System.out.println("hello!!!");
    			}
    	}
    getCount method signature says that it returns an integer value; but there is no return statement in the method.

    Question is would it give a compile time error?
    No compilation error because there is no possible path that leads to the completion of the method (where it has to return an int value). Add the following statement to the loop and see for yourself:

    Java Code:
    if (1 == 2) break; // this will never happen but the compiler doesn't know
    kind regards,

    Jos

  16. #1036
    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

    Vote for Jos comment. But in practice people start to code in this way,

    Java Code:
    public int getCount() {
    }
    and the compile to make sure everything is fine. So you are stuck. ;)

  17. #1037
    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 Ramanjaneyulu View Post
    For this,it will print "Yes",because both reference variables are referring to same String object in String pool.
    Refereed to which question you are commenting?

  18. #1038
    Ramanjaneyulu is offline Member
    Join Date
    Aug 2010
    Posts
    11
    Rep Power
    0

    Default

    Eranga,

    I tried to give reply to one Quiz item in 1st page,later I realize that it was a old one and this thread has 54 pages. So I removed it.

  19. #1039
    Ramanjaneyulu is offline Member
    Join Date
    Aug 2010
    Posts
    11
    Rep Power
    0

    Default

    We know that if one thread is having class lock on an object,no other threads cann't access any other methods of that object.

    Can any one give example to demonstrate the above point.

  20. #1040
    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 Ramanjaneyulu View Post
    Eranga,

    I tried to give reply to one Quiz item in 1st page,later I realize that it was a old one and this thread has 54 pages. So I removed it.
    So you can quote the post you want to comment. It dosen't matte that the post is old or not, still you can comment on it. But without quite the original it not make sense at all.

Page 52 of 55 FirstFirst ... 2425051525354 ... 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
  •