16.  What is the output of this program ?
class output {
public static void main(String args[])
{
String s1 = ‘‘one’‘;
String s2 = s1 + ‘‘ two’‘;
System.out.println(s2);
}
}


one
two
one two
compilation error


Answer

 Option

No answer description available for this question.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

17.  Which of these methods is used to compare a specific region inside a string with another specific region in another string ?


regionMatch()
match()
RegionMatches()
regionMatches()


Answer

 Option

No answer description available for this question.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

18.  Which of the following statement is correct ?


replace() method replaces all occurrences of one character in invoking string with another character.
replace() method replaces only first occurances of a character in invoking string with another character.
replace() method replaces all the characters in invoking string with another character.
replace() replace() method replaces last occurrence of a character in invoking string with another character.


Answer

 Option

No answer description available for this question.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

19.  In the below code, which code fragment should be inserted at line 3 so that the output will be: ‘‘123abc 123abc’‘ ?
StringBuilder sb1 = new StringBuilder(‘‘123’‘);
String s1 = ‘‘123’‘;
// insert code here
System.out.println(sb1 + ‘‘ ‘‘ + s1);


sb1.append(‘‘abc’‘); s1.append(‘‘abc’‘);
sb1.append(‘‘abc’‘); s1.concat(‘‘abc’‘);
sb1.concat(‘‘abc’‘); s1.append(‘‘abc’‘);
sb1.append(‘‘abc’‘); s1 = s1.concat(‘‘abc’‘);


Answer

 Option

append() is stringbuffer method and concat is String class method. append() is stringbuffer method and concat is String class method.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

20.  Which of these method of class String is used to check weather a given object starts with a particular string literal ?


startsWith()
endsWith()
Starts()
ends()


Answer

 Option

No answer description available for this question.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report