1.  Which of the following are the correct ways to increment the value of variable a by 1?
  1. ++a++;
  2. a += 1;
  3. a ++ 1;
  4. a = a +1;
  5. a = +1;
A. 1, 3
B. 2, 4
C. 3, 5
D. 4, 5
E. None of these
Answer: Option B

Solved MCQs From: http://cs-mcqs.blogspot.com

2.  What will be the output of the C#.NET code snippet given below?
byte b1 = 0xF7;
byte b2 = 0xAB;
byte temp;
temp = (byte)(b1 & b2);
Console.Write (temp + " ");
temp = (byte)(b1^b2);
Console.WriteLine(temp);
A. 163 92
B. 92 163
C. 192 63
D. 0 1
Answer: Option A

Solved MCQs From: http://cs-mcqs.blogspot.com

3.  Which of the following is NOT an Arithmetic operator in C#.NET?
A. **B. +
C. /D. %
E. *
Answer: Option A

Solved MCQs From: http://cs-mcqs.blogspot.com

4.  Which of the following are NOT Relational operators in C#.NET?
  1. >=
  2. !=
  3. Not
  4. <=
  5. <>=
A. 1, 3
B. 2, 4
C. 3, 5
D. 4, 5
E. None of these
Answer: Option C

Solved MCQs From: http://cs-mcqs.blogspot.com

5.  Which of the following is NOT a Bitwise operator in C#.NET?
A. &B. |
C. <<D. ^
E. ~
Answer: Option C


Solved MCQs From: http://cs-mcqs.blogspot.com

6.  Which of the following statements is correct about the C#.NET code snippet given below?
int d; 
d = Convert.ToInt32( !(30 < 20) );
A. A value 0 will be assigned to d.
B. A value 1 will be assigned to d.
C. A value -1 will be assigned to d.
D. The code reports an error.
E. The code snippet will work correctly if ! is replaced by Not.
Answer: Option B
Explanation:

Sample Program:
bool falseFlag = false;
bool trueFlag = true;

Console.WriteLine("{0} converts to {1}.", falseFlag,
                  Convert.ToInt32(falseFlag));
Console.WriteLine("{0} converts to {1}.", trueFlag,
                  Convert.ToInt32(trueFlag));
The example displays the following output:

       False converts to 0.
       True converts to 1.
Solved MCQs From: http://cs-mcqs.blogspot.com


7.  Which of the following is the correct output for the C#.NET code snippet given below?
Console.WriteLine(13 / 2 + " " + 13 % 2); 
A. 6.5 1
B. 6.5 0
C. 6 0
D. 6 1
E. 6.5 6.5
Answer: Option D

Solved MCQs From: http://cs-mcqs.blogspot.com

8.  Which of the following statements are correct about the Bitwise & operator used in C#.NET?
  1. The & operator can be used to Invert a bit.
  2. The & operator can be used to put ON a bit.
  3. The & operator can be used to put OFF a bit.
  4. The & operator can be used to check whether a bit is ON.
  5. The & operator can be used to check whether a bit is OFF.
A. 1, 2, 4
B. 2, 3, 5
C. 3, 4
D. 3, 4, 5
E. None of these
Answer: Option D

Solved MCQs From: http://cs-mcqs.blogspot.com

9.  Which of the following are Logical operators in C#.NET?
  1. &&
  2. ||
  3. !
  4. Xor
  5. %
A. 1, 2, 3
B. 1, 3, 4
C. 2, 4, 5
D. 3, 4, 5
E. None of these
Answer: Option A

Solved MCQs From: http://cs-mcqs.blogspot.com

10.  Suppose n is a variable of the type Byte and we wish, to check whether its fourth bit (from right) is ON or OFF. Which of the following statements will do this correctly?
A.
if ((n&16) == 16)
Console.WriteLine("Third bit is ON");
B.
if ((n&8) == 8)
Console.WriteLine("Third bit is ON");
C.
if ((n ! 8) == 8)
Console.WriteLine("Third bit is ON");
D.
if ((n ^ 8) == 8)
Console.WriteLine("Third bit is ON");
E.
if ((n ~ 8) == 8)
Console. WriteLine("Third bit is ON");

Answer: Option B
Explanation:

byte myByte = 153; // In Binary = 10011001

byte n = 8; // In Binary = 00001000 
(Here 1 is the 4th bit from right)

Now perform logical AND operation (n & myByte)

 10011001
 00001000
---------
 00001000  Here result is other than 0, so evaluated to True.
---------
If the result is true, then we can understand that 4th bit is ON of the given data myByte.
Solved MCQs From: http://cs-mcqs.blogspot.com



CONSTRUCTORS


1.  Which of the following statements is correct?
A. A constructor can be used to set default values and limit instantiation.
B. C# provides a copy constructor.
C. Destructors are used with classes as well as structures.
D. A class can have more than one destructor.
Answer: Option A

Solved MCQs From: http://cs-mcqs.blogspot.com

2.  Which of the following statements is correct about the C#.NET code snippet given below?
namespace IndiabixConsoleApplication
{ 
    class Sample
    { 
        public int func()
        {
            return 1;
        } 
        public Single func()
        { 
            return 2.4f ;
        } 
    } 
    class Program
    { 
        static void Main(string[ ] args)
        {
            Sample s1 = new Sample(); 
            int i;
            i = s1.func(); 
            Single j; 
            j = s1.func(); 
        } 
    } 
}
A. func() is a valid overloaded function.
B. Overloading works only in case of subroutines and not in case of functions.
C. func() cannot be considered overloaded because: return value cannot be used to distinguish between two overloaded functions.
D. The call to i = s1.func() will assign 1 to i.
E. The call j = s1.func() will assign 2.4 to j.
Answer: Option C

Solved MCQs From: http://cs-mcqs.blogspot.com

3.  Which of the following ways to create an object of the Sample class given below will work correctly?
class Sample
{
    int i;
    Single j;
    double k;
    public Sample (int ii, Single jj, double kk)
    {
        i = ii;
        j = jj;
        k = kk;
    } 
}
A. Sample s1 = new Sample();
B. Sample s1 = new Sample(10);
C. Sample s2 = new Sample(10, 1.2f);
D. Sample s3 = new Sample(10, 1.2f, 2.4);
E. Sample s1 = new Sample(, , 2.5);
Answer: Option D

Solved MCQs From: http://cs-mcqs.blogspot.com

4.  Which of the following statements are correct about static functions?
  1. Static functions can access only static data.
  2. Static functions cannot call instance functions.
  3. It is necessary to initialize static data.
  4. Instance functions can call static functions and access static data.
  5. this reference is passed to static functions.
A. 1, 2, 4
B. 2, 3, 5
C. 3, 4
D. 4, 5
E. None of these
Answer: Option A

Solved MCQs From: http://cs-mcqs.blogspot.com

5.  Which of the following statements is correct about constructors?
A. If we provide a one-argument constructor then the compiler still provides a zero-argument constructor.
B. Static constructors can use optional arguments.
C. Overloaded constructors cannot use optional arguments.
D. If we do not provide a constructor, then the compiler provides a zero-argument constructor.
Answer: Option D

Solved MCQs From: http://cs-mcqs.blogspot.com


6.  Which of the following is the correct way to define the constructor(s) of the Sample class if we are to create objects as per the C#.NET code snippet given below?
Sample s1 = new Sample(); 
Sample s2 = new Sample(9, 5.6f);
A.
public Sample()
{
    i = 0; 
    j = 0.0f;
}
public Sample (int ii, Single jj)
{
    i = ii;
    j = jj;
}
B.
public Sample (Optional int ii = 0, Optional Single jj = 0.0f)
{
    i = ii;
    j = jj;
}
C.
public Sample (int ii, Single jj)
{
    i = ii;
    j = jj;
}
D.
Sample s;
E.
s = new Sample();

Answer: Option A

Solved MCQs From: http://cs-mcqs.blogspot.com
7.  In which of the following should the methods of a class differ if they are to be treated as overloaded methods?
  1. Type of arguments
  2. Return type of methods
  3. Number of arguments
  4. Names of methods
  5. Order of arguments
A. 2, 4
B. 3, 5
C. 1, 3, 5
D. 3, 4, 5

Answer: Option C


Solved MCQs From: http://cs-mcqs.blogspot.com
8.  Can static procedures access instance data?
A. YesB. No

Answer: Option B

Solved MCQs From: http://cs-mcqs.blogspot.com
9.  Which of the following statements are correct about constructors in C#.NET?
  1. Constructors cannot be overloaded.
  2. Constructors always have the name same as the name of the class.
  3. Constructors are never called explicitly.
  4. Constructors never return any value.
  5. Constructors allocate space for the object in memory.
A. 1, 3, 5
B. 2, 3, 4
C. 3, 5
D. 4, 5
E. None of these

Answer: Option B


Solved MCQs From: http://cs-mcqs.blogspot.com
10.  How many times can a constructor be called during lifetime of the object?
A. As many times as we call it.
B. Only once.
C. Depends upon a Project Setting made in Visual Studio.NET.
D. Any number of times before the object gets garbage collected.
E. Any number of times before the object is deleted.

Answer: Option B

Solved MCQs From: http://cs-mcqs.blogspot.com

11.  Is it possible to invoke Garbage Collector explicitly?
A. YesB. No
Answer: Option A

Solved MCQs From: http://cs-mcqs.blogspot.com
12.  Which of the following statements are correct about the C#.NET code snippet given below?
class Sample
{
    static int i;
    int j;
    public void proc1()
    {
        i = 11; 
        j = 22;
    }
    public static void proc2()
    {
        i = 1;
        j = 2;
    }
    static Sample()
    {
        i = 0; 
        j = 0;
    }
}
A. i cannot be initialized in proc1().
B. proc1() can initialize i as well as j.
C. j can be initialized in proc2().
D. The constructor can never be declared as static.
E. proc2() can initialize i as well as j.
Answer: Option B

Solved MCQs From: http://cs-mcqs.blogspot.com
13.  Which of the following statements is correct?
A. There is one garbage collector per program running in memory.
B. There is one common garbage collector for all programs.
C. An object is destroyed by the garbage collector when only one reference refers to it.
D. We have to specifically run the garbage collector after executing Visual Studio.NET.
Answer: Option B

Solved MCQs From: http://cs-mcqs.blogspot.com
14.  Is it possible for you to prevent an object from being created by using zero argument constructor?
A. YesB. No
Answer: Option A

Solved MCQs From: http://cs-mcqs.blogspot.com
15.  Which of the following statements are correct about static functions?
A. Static functions are invoked using objects of a class.
B. Static functions can access static data as well as instance data.
C. Static functions are outside the class scope.
D. Static functions are invoked using class.
Answer: Option D

Solved MCQs From: http://cs-mcqs.blogspot.com

16.  What will be the output of the C#.NET code snippet given below?
namespace IndiabixConsoleApplication
{ 
    class Sample
    { 
        static Sample()
        { 
            Console.Write("Sample class ");
        }
        public static void Bix1()
        { 
            Console.Write("Bix1 method ");
        } 
    } 
    class MyProgram
    { 
        static void Main(string[ ] args)
        { 
            Sample.Bix1();
        } 
    } 
}
A. Sample class Bix1 method
B. Bix1 method
C. Sample class
D. Bix1 method Sample class
E. Sample class Sample class
Answer: Option A

Solved MCQs From: http://cs-mcqs.blogspot.com
17.  Which of the following statements is correct about constructors in C#.NET?
A. A constructor cannot be declared as private.
B. A constructor cannot be overloaded.
C. A constructor can be a static constructor.
D. A constructor cannot access static data.
E. this reference is never passed to a constructor.
Answer: Option C

Solved MCQs From: http://cs-mcqs.blogspot.com
18.  What will be the output of the C#.NET code snippet given below?
namespace IndiabixConsoleApplication
{
    class Sample
    { 
        public static void fun1()
        { 
            Console.WriteLine("Bix1 method");
        }
        public void fun2()
        { 
            fun1(); 
            Console.WriteLine("Bix2 method");
        }
        public void fun2(int i)
        { 
            Console.WriteLine(i);
            fun2(); 
        } 
    } 
    class MyProgram
    { 
        static void Main(string[ ] args)
        { 
            Sample s = new Sample(); 
            Sample.fun1(); 
            s.fun2(123);
        } 
    } 
}
A.
Bix1 method 
123
Bixl method 
Bix2 method
B.
Bix1 method 
123
Bix2 method
C.
Bix2 method 
123
Bix2 method 
Bixl method
D.
Bixl method
123
E.
Bix2 method 
123
Bixl method
Answer: Option A

Solved MCQs From: http://cs-mcqs.blogspot.com



STRINGS


1.  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 by s2.
  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

Solved MCQs From: http://cs-mcqs.blogspot.com
2.  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. AREB. CRE
C. CRD. REA
E. CREATED
Answer: Option B

    Solved MCQs From: http://cs-mcqs.blogspot.com

3.  Which of the following statements will correctly copy the contents of one string into another ?
A.
String s1 = "String";
String s2; 
s2 = s1;
B.
String s1 = "String" ; 
String s2;
s2 = String.Concat(s1, s2);
C.
String s1 = "String"; 
String s2;
s2 = String.Copy(s1);
D.
String s1 = "String"; 
String s2;
s2 = s1.Replace();
E.
String s1 = "String"; 
String s2;
s2 = s2.StringCopy(s1);
Answer: Option C

Solved MCQs From: http://cs-mcqs.blogspot.com
4.  The string built using the String class are immutable (unchangeable), whereas, the ones built- using the StringBuilder class are mutable.
A. TrueB. False
Answer: Option A

Solved MCQs From: http://cs-mcqs.blogspot.com
5.  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

Solved MCQs From: http://cs-mcqs.blogspot.com


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

Solved MCQs From: http://cs-mcqs.blogspot.com
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: Option E

Solved MCQs From: http://cs-mcqs.blogspot.com
8.  Which of the following snippets are the correct way to convert a Single into a String?
  1. Single f = 9.8f; 
    String s;
    s = (String) (f);
  2. Single f = 9.8f; 
    String s;
    s = Convert.ToString(f);
  3. Single f = 9.8f; 
    String s;
    s = f.ToString();
  4. Single f = 9.8f; 
    String s;
    s = Clnt(f);
  5. Single f = 9.8f; 
    String s;
    s = CString(f);
A. 1, 2
B. 2, 3
C. 1, 3, 5
D. 2, 4
Answer: Option B
Explanation:

Solved MCQs From: http://cs-mcqs.blogspot.com
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: Option B

Solved MCQs From: http://cs-mcqs.blogspot.com

10.  Which of the following is correct way to convert a String to an int?
  1. String s = "123"; 
    int i;
    i = (int)s;
  2. String s = "123";
    int i;
    i = int.Parse(s);
  3. String s = "123"; 
    int i;
    i = Int32.Parse(s);
  4. String s = "123"; 
    int i;
    i = Convert.ToInt32(s);
  5. String s = "123"; 
    int i;
    i = CInt(s);
A. 1, 3, 5
B. 2, 4
C. 3, 5
D. 2, 3, 4
Answer: Option D
Explanation:

Solved MCQs From: http://cs-mcqs.blogspot.com


11.  Which of the following statements about a String is correct?
A. A String is created on the stack.
B. Whether a String is created on the stack or the heap depends on the length of the String.
C. A String is a primitive.
D. A String can be created by using the statement String s1 = new String;
E. A String is created on the heap.
Answer: Option E

Solved MCQs From: http://cs-mcqs.blogspot.com
12.  Which of the following statement is correct about a String in C#.NET?
A. A String is mutable because it can be modified once it has been created.
B. Methods of the String class can be used to modify the string.
C. A number CANNOT be represented in the form of a String.
D. A String has a zero-based index.
E. The System.Array class is used to represent a string.
Answer: Option D

Solved MCQs From: http://cs-mcqs.blogspot.com
13.  Which of the following will be the correct output for the C#.NET code snippet given below?
String s1 = "Five Star";
String s2 = "FIVE STAR";
int c;
c = s1.CompareTo(s2);
Console.WriteLine(c);
A. 0B. 1
C. 2D. -1
E. -2
Answer: Option D

Solved MCQs From: http://cs-mcqs.blogspot.com
14.  If s1 and s2 are references to two strings then which of the following are the correct ways to find whether the contents of the two strings are equal?
  1. if(s1 = s2)
  2. if(s1 == s2)
  3. int c;
    c = s1.CompareTo(s2);
  4. if( strcmp(s1, s2) )
  5. if (s1 is s2)
A. 1, 2
B. 2, 3
C. 4, 5
D. 3, 5
Answer: Option B

Solved MCQs From: http://cs-mcqs.blogspot.com
15.  Which of the following statements are correct about the String Class in C#.NET?
  1. Two strings can be concatenated by using an expression of the form s3 = s1 + s2;
  2. String is a primitive in C#.NET.
  3. A string built using StringBuilder Class is Mutable.
  4. A string built using String Class is Immutable.
  5. Two strings can be concatenated by using an expression of the form s3 = s1&s2;
A. 1, 2, 5
B. 2, 4
C. 1, 3, 4
D. 3, 5
Answer: Option C

Solved MCQs From: http://cs-mcqs.blogspot.com


16.  Which of the following statements are correct?
  1. String is a value type.
  2. String literals can contain any character literal including escape sequences.
  3. The equality operators are defined to compare the values of string objects as well as references.
  4. Attempting to access a character that is outside the bounds of the string results in an IndexOutOfRangeException.
  5. The contents of a string object can be changed after the object is created.
A. 1, 3
B. 3, 5
C. 2, 4
D. 1, 2, 4
Answer: Option C

Solved MCQs From: http://cs-mcqs.blogspot.com
17.  Which of the following is the correct way to find out the index of the second 's' in the string "She sells sea shells on the sea-shore"?
A.
String str = "She sells sea shells on the sea-shore"; 
int i;
i = str.SecondIndexOf("s");
B.
String str = "She sells sea shells on the sea-shore"; 
int i, j;
i = str.FirstIndexOf("s"); 
j = str.IndexOf("s", i + 1);
C.
String str = "She sells sea shells on the sea-shore"; 
int i, j;
i = str.IndexOf("s"); 
j = str.IndexOf("s", i + 1);
D.
String str = "She sells sea shells on the sea-shore"; 
int i, j;
i = str.LastIndexOf("s"); 
j = str.IndexOf("s", i - 1);
E.
String str = "She sells sea shells on the sea-shore"; 
int i, j;
i = str.IndexOf("S"); 
j = str.IndexOf("s", i);
Answer: Option C

Solved MCQs From: http://cs-mcqs.blogspot.com






 
Top