Hima<BR>Sun Certified Java Programmer
Originally posted by Axel Janssen:
Hi,
so Java interpretes the parameter null as a String???
O.k. every object can be null. But Java takes null as every object???
Axel
Originally posted by kriti sharma:
hi hima,
ur first 4 doubts r being efficiently solved.
i am solving 4 & 5.
always remember that the most specific option is selected.
here String is more specific then Object so it gets selected.
in the 5th code both String & StringBuffer are equally specific
hence compiler complains of ambiguity.
hope this clears ur doubt.
kriti
Originally posted by kriti sharma:
hi hima,
ur first 4 doubts r being efficiently solved.
i am solving 4 & 5.
always remember that the most specific option is selected.
here String is more specific then Object so it gets selected.
in the 5th code both String & StringBuffer are equally specific
hence compiler complains of ambiguity.
hope this clears ur doubt.
kriti
Hima<BR>Sun Certified Java Programmer
Hima<BR>Sun Certified Java Programmer
Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Hima<BR>Sun Certified Java Programmer
Originally posted by Hima Mangal:
1. if( "String".endsWith(""))
System.out.println("True");
else
System.out.println("False");
The code produces True
3. if("String".replace('g','G') == "String".replace('g','G'))
System.out.println("Equal");
else
System.out.println("Not Equal");
The code prints "Not Equal".
4. if(" String ".trim() == "String")
System.out.println("Equal");
else
System.out.println("Not Equal");
The code prints "Not Equal".
Jane Griscti
SCJP, Co-author Mike Meyers' Java 2 Certification Passport
Hima<BR>Sun Certified Java Programmer