Page 6 of 55 FirstFirst ... 4567816 ... LastLast
Results 101 to 120 of 1093

Thread: Quiz Time

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

    Default

    Yep, normally called as unclosed character literal. :)

    So what is the different of,

    Java Code:
            System.out.println((String)"Java");
    and,

    Java Code:
            System.out.println("Java");

  2. #102
    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
    Yep, normally called as unclosed character literal. :)

    So what is the different of,

    Java Code:
            System.out.println((String)"Java");
    and,

    Java Code:
            System.out.println("Java");
    I think there is no such an difference

    Eranga ......What about last ans
    sanjeev,संजीव

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

    Default

    Quote Originally Posted by sanjeevtarar View Post
    I think there is no such an difference

    There is no difference. Just casting confused. I see lots of time newbies confused on this. actually println() do all those things for you. :)


    Quote Originally Posted by sanjeevtarar View Post
    Eranga ......What about last ans
    What you mean Sanjeev. I answered to it on post #101.

  4. #104
    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

    What you mean Sanjeev. I answered to it on post #101.
    OK DEAR.............

    moreeeeeeeeeeee......

    sanjeev,संजीव

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

    Default

    Oh Quiz Time :D

    I AM BACK !!!
    i am the future

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

    Default

    who is going to take the honor to sum up all the puzzles and there answer along with incorrect one as well as cool moments ;) of this thread ...
    i am the future

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

    Default

    I don't think it's much better. We do this just to catchup something. Some answers are not given honestly, try to pointed something. Isn't it?

    So it's better to keep going like this.

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

    Default once againg STRING comaprison by ==

    predict the output!! an as rule says, don't compile it just see and post the answer

    Java Code:
    package com.faaltu.Quiz;
    
    public class StringInternTest {
    	public static void main(String[] args) {
    		String str1 = "string";
    		String str2 = new String("string");
    		String str3 = new String("string").intern();
    		
    		if ( str1 == str2){
    			System.out.println("\nSAME");
    		}else{
    			System.out.println("\nNEAH");
    		}
    		
    		if ( str1 == str3){
    			System.out.println("\nSAME");
    		}else{
    			System.out.println("\nNEAH");
    		}
    		
    		if ( str2 == str3){
    			System.out.println("\nSAME");
    		}else{
    			System.out.println("\nNEAH");
    		}
    			
    	}
    }
    i am the future

  9. #109
    Zosden's Avatar
    Zosden is offline Senior Member
    Join Date
    Apr 2008
    Posts
    384
    Rep Power
    7

    Default

    Neah

    Yeah

    Yeah
    My IP address is 127.0.0.1

  10. #110
    Zosden's Avatar
    Zosden is offline Senior Member
    Join Date
    Apr 2008
    Posts
    384
    Rep Power
    7

    Default

    How is mine two long it has everything you guys have talked about with objects , and then some so instead of posting 5 little ones I did one big one.
    My IP address is 127.0.0.1

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

    Default

    NEAH NEAH NEAH

    You are wrong,

    try again,

    How is mine two long it has everything you guys have talked about with objects , and then some so instead of posting 5 little ones I did one big one.
    My friend as said already, keep only the catchy part! that puzzle looks lika an essay :cool:
    Last edited by rjuyal; 05-12-2008 at 05:52 PM. Reason: PHP code should not be used ;) for Simple quote
    i am the future

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

    Default



    Is it correct?

    NEAH

    SAME

    NEAH

    sanjeev,संजीव

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

    Default correct

    Thts Right Sanjeev,

    What's the answer of this:-

    package com.faaltu.Quiz;

    one more

    Java Code:
    public class StringInternTest {
    	public static void main(String[] args) {
    		String str1 = "string";
    		String str2 = new String("string").intern();
    		String str3 = new String("string").intern();
    		
    		if ( str1 == str2){
    			System.out.println("\nSAME");
    		}else{
    			System.out.println("\nNEAH");
    		}
    		
    		if ( str1 == str3){
    			System.out.println("\nSAME");
    		}else{
    			System.out.println("\nNEAH");
    		}
    		
    		if ( str2 == str3){
    			System.out.println("\nSAME");
    		}else{
    			System.out.println("\nNEAH");
    		}
    			
    	}
    }
    i am the future

  14. #114
    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 rjuyal View Post
    Thts Right Sanjeev,

    What's the answer of this:-

    package com.faaltu.Quiz;

    one more

    Java Code:
    public class StringInternTest {
    	public static void main(String[] args) {
    		String str1 = "string";
    		String str2 = new String("string").intern();
    		String str3 = new String("string").intern();
    		
    		if ( str1 == str2){
    			System.out.println("\nSAME");
    		}else{
    			System.out.println("\nNEAH");
    		}
    		
    		if ( str1 == str3){
    			System.out.println("\nSAME");
    		}else{
    			System.out.println("\nNEAH");
    		}
    		
    		if ( str2 == str3){
    			System.out.println("\nSAME");
    		}else{
    			System.out.println("\nNEAH");
    		}
    			
    	}
    }
    SAME

    SAME

    SAME

    because you are using intern()........which causes new String object to point existing one if any exist.
    sanjeev,संजीव

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

    Default

    es el correcto! :D


    next puzzle please
    i am the future

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

    Default

    Hi, guys. I'm back here. :)

    I would like to make a request from all of you guys. Please don't use PHP tags when posting codes or quotes in forums. It's make the browser keep too wide on the scree. :)

    Thanks
    Eranga

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

    Default Another Quiz: Constructor Vs Parsing

    Java Code:
    package com.faaltu.temp;
    
    public class IntegerTest {
    	public static void main(String[] args) {
    		System.out.println("constructor: " + new Integer("hello"));
    		System.out.println("parsing: " + Integer.parseInt("hello"));
    	}
    }

    what will be the output?
    and as the rule say "Don't compile it, just read and try to answer"!!
    i am the future

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

    Default

    Ah, I caught you :)

    You comes with NumberFormatException. Required a integer value, but found a String object there in the second println().

    Actually you need a String there. But it should be containing an int representation.

    Is that my explanation is ok?

  19. #119
    Jesdisciple is offline Member
    Join Date
    May 2008
    Posts
    22
    Rep Power
    0

    Default

    LOL, still waiting eh?

    I think it would print "no" because == compares objects and the two strings are actually different objects with identical values under the hood.

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

Page 6 of 55 FirstFirst ... 4567816 ... 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
  •