wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Strings" Watch "Strings" New topic
Author

Strings

Arun Pai
Ranch Hand

Joined: Mar 11, 2002
Posts: 143
What are legal operations on s?
String s = "something";
A.s >>= "ok";
B.char c = s[4];
C.s += 3;
D.s -= "thing";
E.s = s + "good";

Answer is C & E ??
-Arun
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
Because it's possible to concatenate strings with the + operator. But it isn't possible to substract, shift or access them as they would be a char array.


SCJP2. Please Indent your code using UBB Code
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

Originally posted by Jose Botella:
Because it's possible to concatenate strings with the + operator. But it isn't possible to substract, shift or access them as they would be a char array.

Exactly -- in Java the + operator is overloaded -- meaning it has a different function depending on the type of operands it is used with.
So C would produce the string "Something3"
and E would produce the string "Somethinggood"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Strings