1.  Which of these operators can be used to concatenate two or more String objects ?


+
+=
&
||


Answer

 Option

string s1 = “Hello”+ ” I ” + “Love” + ” PrintExam “; Console.WriteLine(s1); Hello I Love PrintExam.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

2.  What will be the output for the given set of code ?
String a = ‘’Csharp’’;
String b = ‘’CSHARP’’;
int c;
c = a.CompareTo(b);
Console.WriteLine(c);


0.
1
2
-1


Answer

 Option

Negative integer -1 is returned as ‘a’ is less than ‘b’ by CompareTo() method.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

3.  What is output for the following set of Code ?
static void Main(string[] args)
{
String obj = ‘’hello’’;
String obj1 = ‘’world’’;
String obj2 = obj;
string s = obj+’’ ‘’+obj1;
Console.WriteLine(s.IndexOf('r'));
Console.ReadLine();
}


7
8
9
10


Answer

 Option

IndexOf() used to find absolute position of a character of substring.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

4.  Which of the following statements about a String is correct ?


A String is created on the stack.
Whether a String is created on the stack or the heap depends on the length of the String.
A String is a primitive.
A String is created on the heap.


Answer

 Option

No answer description available for this question.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report

5.  Which of these data type values is returned by equals() method of String class ?


char
int
boolean
All of the mentioned


Answer

 Option

equals() method of string class returns boolean value true if both the strings are equal and false if they are unequal.

Workspace

Report
Mail id: Report Error:

Answer Workspace Report