MCQs
replace() method replaces all occurrences of one character in invoking string with another character. s1.replace('l','w') replaces every occurrence of 'l' in hello by 'w', giving hewwo.
Output:
$ javac output.java
$ java output
hewwo
None .
None.
Output:
$ javac output.java
$ java output
one two
startsWith() method is case sensitive "hello" and "Hello" are treated differently, hence false
is stored in var.
Output:
$ javac output.java
$ java output
false
StringBuffer class is used to create strings that can be modified after they are created.
equals() method of string class returns boolean value true if both the string are equal and false
if they are unequal.
replace() method replaces all occurrences of one character in invoking string with another character.
None
compareTo() function returns zero when both the strings are equal, it returns a value less than
zero if the invoking string is less than the other string being compared and value greater than
zero when invoking string is greater than the string compared to.
compareTo() function returns zero when both the strings are equal, it returns a value less than
zero if the invoking string is less than the other string being compared and value greater than
zero when invoking string is greater than the string compared to.