Friday, 16 December 2011

91.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: Option E

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

String s1 = "Nagpur";
String s2;
s2 = s1.insert(6, "Mumbai");
Console.WriteLine(s2);
A.NagpuMumbair
B.Nagpur Mumbai
C.Mumbai
D.Nagpur
E.NagpurMumbai
Answer: Option E

89. Which of the following statements will correctly copy the contents of one string into another ?


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

String s1 = "ALL MEN ARE CREATED EQUAL";
String s2;
s2 = s1.Substring(12, 3);
Console.WriteLine(s2);
A.ARE
B.CRE
C.CR
D.REA
E.CREATED       
Answer: Option B

87.Which of the following statements are true about the C#.NET code snippet given below?

String s1, s2;
s1 = "Hi";
s2 = "Hi";
1.String objects cannot be created without using new.
2.Only one object will get created.
3.s1 and s2 both will refer to the same object.
4.Two objects will get created, one pointed to by s1 and another pointed to bys2.
5.s1 and s2 are references to the same object.
A.1, 2, 4
B.2, 3, 5
C.3, 4
D.2, 5
Answer: Option B

85.Which of the following is the correct way to implement a read only property Length in aSample class?

A.class Sample
{
    int len;
    public int Length
    {
        get
        {
            return len;
        }
    }
}
B.class Sample
{
    public int Length
    {
        get
        {
            return Length;
        }
    }
}
C.class Sample
{
    int len;
    public int Length
    {
        get
        {
            return len;
        }
        set
        {
            len = value;
        }
    }
}
D.class Sample
{
    int len;
    public int Length
    {
        Readonly get
        {
            return len;
        }
    }
}
Answer: Option A

84.Which of the following statements is correct about properties used in C#.NET?

A.Every property must have a set accessor and a get accessor.
B.Properties cannot be overloaded.
C.Properties of a class are actually methods that work like data members.
D.A property has to be either read only or a write only.
Answer: Option C