KnowledgeBoat Logo
|

Computer Applications

Suppose that s1 and s2 are two strings. Which of the statements or expressions are incorrect ?

  1. String s3 = s1 + s2;
  2. String s3 = s1 - s2;
  3. s1.compareTo(s2);
  4. int m = s1.length( );

Java String Handling

9 Likes

Answer

String = s1 - s2;

Reason — - operator cannot be used with String objects, hence the statement String s3 = s1 - s2; is incorrect.

Answered By

3 Likes


Related Questions