Page 3 of 55 FirstFirst 123451353 ... LastLast
Results 41 to 60 of 1093

Thread: Quiz Time

  1. #41
    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. #42
    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 really love this thread now. Oh dear, where others in our community.
    Eranga.........Where are other Questionsssss..
    sanjeev,संजीव

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

    Default

    Java Code:
            System.out.println(strObjThree == strObjOne);
     
            System.out.println(strObjThree == strObjTwo);
            System.out.println(strObjThree.equals(strObjTwo));

    is the answer true,false,true :(


    @SANJEEV

    let me try for '==' vs equals


    '==' compares the reference in case of Object. If both referring to same then true otherwise false

    "equals" first compares the reference ( using '==' ) then any other logic afterwards

    please let me know if i am wrong
    i am the future

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

    Default

    PHP Code:
    I really love this thread now. Oh dear, where others in our community.
    this thread will be biggest :rolleyes:



    Sanjeev your turn, ask the quiz
    i am the future

  5. #45
    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


    Sanjeev your turn, ask the quiz
    Yes it's. It's your turn Sanjeev now.

  6. #46
    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
    "equals" first compares the reference ( using '==' ) then any other logic afterwards
    Actually equals() method compares the characters that make up a String object.

    Even though process is different. It actually creates two char arrays and puts the characters of each String objects in separate array and then performs the comparison.

  7. #47
    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
    Actually equals() method compares the characters that make up a String object.

    Even though process is different. It actually creates two char arrays and puts the characters of each String objects in separate array and then performs the comparison.
    Exactly Eranga.....
    sanjeev,संजीव

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

    See the advantage to get familiar with much better ways in coding. :) Our newbie can learn a lot on this thread too.

    So where is the next question? ;)

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

    Default

    EQUALS CODE of STRING CLASS

    Java Code:
    if (this == anObject) {
    	    return true;
    	}
    	if (anObject instanceof String) {
    	    String anotherString = (String)anObject;
    	    int n = count;
    	    if (n == anotherString.count) {
    		char v1[] = value;
    		char v2[] = anotherString.value;
    		int i = offset;
    		int j = anotherString.offset;
    		while (n-- != 0) {
    		    if (v1[i++] != v2[j++])
    			return false;
    		}
    		return true;
    	    }
    	}
    	return false;

    anyways... next question please
    :o
    i am the future

  10. #50
    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

    Yep, nice work pal. If anyone can write similar application that libraries done, we can lean a lot. When I start work on Java I do this.

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

    Default

    Yeah, "yes" should be printed.....
    freedom exists in the world of ideas

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

    Exclamation original code

    I didn't wrote this code, i just did a CtrlC CtrlV from String Class Code :p
    i am the future

  13. #53
    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. #54
    rjuyal's Avatar
    rjuyal is offline Senior Member
    Join Date
    Mar 2008
    Location
    Delhi, India
    Posts
    194
    Rep Power
    7

    Default One more

    One more in this Thread, sukatoa welcome

    and post some Quiz here
    i am the future

  15. #55
    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

    Yes, Sukatoa you can join with us. Just make a quiz and send it to here. But don't use any IDE for answering. Used only for write your question.

    Seems Sanjeev try to make us a big trouble. May be he's designing a much better question for us. :);)

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

    Default

    PHP Code:
    Seems Sanjeev try to make us a big trouble. May be he's desig
    lol DDDD:D
    i am the future

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

    Default Once More

    Java Code:
    public class OneMoreEasyOne {	
    	public static void main(String[] args) {
    		int a = 5;
    		System.out.println("Value is: - " + ( ( a > 5 ) ? 2.3 : 2) );
    	}
    }

    What will it print?
    i am the future

  18. #58
    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 think it should be,

    Java Code:
    Value is - 2.3
    What you give me this time. ;)

  19. #59
    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 think it should be,

    Java Code:
    Value is - 2.3
    What you give me this time. ;)
    Value will be 2, because a > 5 is false, a >= 5 is true
    Last edited by sanjeevtarar; 05-08-2008 at 12:37 PM.
    sanjeev,संजीव

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

    Default and i thought!

    i thought Eranga can't be wrong

    But this time you are :D
    BTW, what's the logic behing 2.3

    i will post the answer with reason after this :)
    i am the future

Page 3 of 55 FirstFirst 123451353 ... 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
  •