Strings c programming questions

6.

If s1 and s2 are references to two strings, then which of the following is the correct way to compare the two references?
A.     s1 is s2
B.     s1 = s2
C.     s1 == s2
D.     strcmp(s1, s2)
E.     s1.Equals(s2)
Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
7.

What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
class SampleProgram
{
static void Main(string[ ] args)
{
string str= “Hello World!”;
Console.WriteLine( String.Compare(str, “Hello World?” ).GetType() );
}
}
}

A.     0
B.     1
C.     String
D.     Hello World?
E.     System.Int32
Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
8.

Which of the following snippets are the correct way to convert a Single into a String?

Single f = 9.8f;
String s;
s = (String) (f);

Single f = 9.8f;
String s;
s = Convert.ToString(f);

Single f = 9.8f;
String s;
s = f.ToString();

Single f = 9.8f;
String s;
s = Clnt(f);

Single f = 9.8f;
String s;
s = CString(f);

A.     1, 2
B.     2, 3
C.     1, 3, 5
D.     2, 4
Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
9.

Which of the following will be the correct output for the C#.NET code snippet given below?

String s1=”Kicit”;
Console.Write(s1.IndexOf(‘c’) + ” “);
Console.Write(s1.Length);

A.     3 6
B.     2 5
C.     3 5
D.     2 6
E.     3 7
Answer & Explanation

Answer: Option B

Explanation:

No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
10.

Which of the following is correct way to convert a String to an int?

String s = “123”;
int i;
i = (int)s;

String s = “123”;
int i;
i = int.Parse(s);

String s = “123”;
int i;
i = Int32.Parse(s);

String s = “123”;
int i;
i = Convert.ToInt32(s);

String s = “123”;
int i;
i = CInt(s);

A.     1, 3, 5
B.     2, 4
C.     3, 5
D.     2, 3, 4
Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question.

Leave a Reply0

Your email address will not be published.