Java OCA OCP Practice Question 1061

Question

In java, Strings are immutable.

A direct implication of this is...

Select 2 options

  • A. you cannot call methods like "1234".replace(' 1', '9'); and expect to change the original String.
  • B. you cannot change a String object, once it is created.
  • C. you can change a String object only by the means of its methods.
  • D. you cannot extend String class.
  • E. you cannot compare String objects.


Correct Options are: A B

Note

A. is correct. calling such methods do not change this object.

They create a new String object.

You can have a final class whose objects are mutable.

String class implements Comparable interface.




PreviousNext

Related