Google News
logo
C# - Quiz(MCQ)
A)
print ("Hello World");
B)
System.out.println("Hello World");
C)
Console.WriteLine("Hello World");
D)
None of the Above

Correct Answer : Option (C) :   Console.WriteLine("Hello World");

A)
# This is a comment
B)
// This is a comment
C)
/* This is a comment
D)
None of the Above

Correct Answer : Option (B) :   // This is a comment

A)
public static void main()
B)
public static void Main()
C)
public static void Program()
D)
None of the Above

Correct Answer : Option (B) :   public static void Main()

A)
Int32
B)
Double
C)
Decimal
D)
All of the Above

Correct Answer : Option (D) :   All of the Above

A)
string
B)
str
C)
Txt
D)
myString

Correct Answer : Option (A) :   string

A)
x = 5;
B)
num x = 5
C)
int x = 5;
D)
double x = 5;

Correct Answer : Option (C) :   int x = 5;

A)
int x = 2.8;
B)
int x = 2.8D;
C)
byte x = 2.8
D)
double x = 2.8D;

Correct Answer : Option (D) :   double x = 2.8D;

A)
length
B)
Length
C)
length()
D)
getLength()

Correct Answer : Option (B) :   Length

A)
Long
B)
String
C)
Boolean
D)
None of the Above

Correct Answer : Option (B) :   String

A)
It allows assignment of null to value type.
B)
It allows assignment of null to static class.
C)
It allows assignment of null to reference type.
D)
None of the Above

Correct Answer : Option (A) :   It allows assignment of null to value type.

A)
True
B)
False
C)
None of the Above
D)
--

Correct Answer : Option (B) :   False

A)
( )
B)
{ }
C)
[ ]
D)
None of the Above

Correct Answer : Option (C) :   [ ]

A)
Class type
B)
String type
C)
Reference type
D)
Value type

Correct Answer : Option (D) :   Value type

14 .
10 > 9 ? "10 is greater than 9" : "9 is greater than 10" is an example of _______
A)
Inverse operator
B)
Conditional operator
C)
Ternary operator
D)
Greater than operator

Correct Answer : Option (C) :   Ternary operator

A)
Static
B)
Mutable
C)
Immutable
D)
Value type

Correct Answer : Option (D) :   Immutable

A)
MyMethod( )
B)
MyMethod
C)
(MyMethod)
D)
myMethod[ ]

Correct Answer : Option (A) :   MyMethod( )

A)
MyMethod( );
B)
MyMethod;
C)
(MyMethod);
D)
myMethod[ ];

Correct Answer : Option (A) :   MyMethod( );

A)
class( )
B)
class
C)
MyClass
D)
className

Correct Answer : Option (B) :   class

A)
-1
B)
0.0
C)
0
D)
1

Correct Answer : Option (C) :   0

A)
int[ ] intArray = new int[ ];
B)
int[5] intArray = new int[ ];
C)
int intArray[ ] = new int[5];
D)
int[ ] intArray = new int[5];

Correct Answer : Option (D) :   int[ ] intArray = new int[5];

A)
Event
B)
Delegate
C)
Utility function
D)
Generic Class

Correct Answer : Option (B) :   Delegate

22 .
Return type of Predicate<T>() is always a ______.
A)
boolean
B)
int
C)
void
D)
string

Correct Answer : Option (A) :   boolean

A)
new myObj = MyClass();
B)
class MyClass = new myObj();
C)
class myObj = new MyClass();
D)
MyClass myObj = new MyClass();

Correct Answer : Option (D) :   MyClass myObj = new MyClass();

A)
True
B)
False
C)
None of the Above
D)
--

Correct Answer : Option (A) :   True

A)
void
B)
const
C)
enum
D)
special

Correct Answer : Option (C) :   enum

A)
Language Integrated Query
B)
Lazy Integrated Query
C)
Local Integration Query
D)
Language Included Query

Correct Answer : Option (A) :   Language Integrated Query

A)
Any time
B)
Runtime
C)
Compile time
D)
Application Initialization time.

Correct Answer : Option (C) :   Compile time

A)
C# is designed for Common Language Infrastructure (CLI).
B)
C# was developed by Anders Hejlsberg and his team during the development of .Net Framework.
C)
C# is a modern, general-purpose, object-oriented programming language developed by Microsoft.
D)
All of the Above.

Correct Answer : Option (D) :   All of the Above.

A)
You can store any type of value in the dynamic data type variable.
B)
Type checking for these types of variables takes place at run-time.
C)
Both (A) and (B)
D)
None of the Above.

Correct Answer : Option (C) :   Both (A) and (B)

A)
%
B)
*
C)
x
D)
#

Correct Answer : Option (B) :   *

A)
return
B)
get
C)
void
D)
break

Correct Answer : Option (A) :   return

A)
while (x > y)
B)
while x > y:
C)
while x > y {
D)
x > y while {

Correct Answer : Option (A) :   while (x > y)

A)
ToChar
B)
ToSingle
C)
ToString
D)
ToDateTime

Correct Answer : Option (D) :   ToDateTime


Explanation : ToDateTime() method converts a type (integer or string type) to date-time structures.

A)
ToType
B)
ToUInt16
C)
ToUInt32
D)
ToUInt64

Correct Answer : Option (D) :   ToUInt64

A)
public
B)
private
C)
abstract
D)
final

Correct Answer : Option (B) :   private

A)
if x > y:
B)
if x > y then:
C)
if (x > y)
D)
None of the Above

Correct Answer : Option (C) :   if (x > y)

A)
You can assign true, false, or null in a Nullable variable.
B)
You can store any value from -2,147,483,648 to 2,147,483,647 or null in a Nullable variable.
C)
C# provides a special data types, the nullable types, to which you can assign normal range of values as well as null values.
D)
All of the Above.

Correct Answer : Option (D) :   All of the Above.

A)
line
B)
elif
C)
endif
D)
region

Correct Answer : Option (A) :   line


Explanation : line − It lets you modify the compiler's line number and (optionally) the file name output for errors and warnings.

A)
as
B)
foreach
C)
abstract
D)
All of the Above.

Correct Answer : Option (D) :   All of the Above.

A)
true
B)
false
C)
None of the Above
D)
--

Correct Answer : Option (A) :   true


Explanation : Value type variables in C# are derived from the class System.ValueType.

A)
ToDouble
B)
ToDecimal
C)
ToInt16
D)
ToInt32

Correct Answer : Option (B) :   ToDecimal


Explanation : ToDecimal() method converts a floating point or integer type to a decimal type.

A)
The catch keyword indicates the catching of an exception.
B)
A program catches an exception with an exception handler at the place in a program where you want to handle the problem.
C)
Both (A) and (B)
D)
None of the Above

Correct Answer : Option (C) :   Both (A) and (B)

A)
The using keyword states that the program is using the names in the given namespace.
B)
A namespace is designed for providing a way to keep one set of names separate from another.
C)
The class names declared in one namespace does not conflict with the same class names declared in another.
D)
All of the Above.

Correct Answer : Option (D) :   All of the Above.

A)
Length
B)
IsStatic
C)
IsFixedSize
D)
None of the Above.

Correct Answer : Option (C) :   IsFixedSize

A)
Protected Internal
B)
Private
C)
Internal
D)
Protected

Correct Answer : Option (A) :   Protected Internal

A)
exports
B)
using
C)
imports
D)
None of the Above.

Correct Answer : Option (B) :   using

47 .
Which of the following statements are TRUE about the .NET CLR?
 
1. It provides a language-neutral development & execution environment.
2. It ensures that an application would not be able to access memory that it is not authorized to access.
3. It provides services to run "managed" applications.
4. The resources are garbage collected.
5. It provides services to run "unmanaged" applications.
A)
Only 1 and 2
B)
1, 2, 3, 4
C)
Only 4 and 5
D)
Only 1, 2 and 4

Correct Answer : Option (B) :   1, 2, 3, 4

A)
sn
B)
ildasm
C)
dumpbin
D)
ngen

Correct Answer : Option (D) :   ngen

A)
Common Type System
B)
Component Object Model
C)
.NET class libraries
D)
Common Language Infrastructure

Correct Answer : Option (C) :   .NET class libraries

A)
They contain a reference to the variables.
B)
Example of built-in reference types are: object, dynamic, and string.
C)
The reference types do not contain the actual data stored in a variable.
D)
All of the Above.

Correct Answer : Option (D) :   All of the Above.

A)
ToInt16
B)
ToInt32
C)
ToDouble
D)
ToDecimal

Correct Answer : Option (A) :   ToInt16


Explanation : ToInt16() method converts a type to a 16-bit integer.

52 .
What does the following C#.NET code snippet will print?
int i = 0, j = 0; 

label:
    i++;
    j+=i;
if (i < 10)
{
    Console.Write(i +" ");
    goto label; 
}
A)
Prints 0 to 8
B)
Prints 1 to 9
C)
Prints 2 to 8
D)
Prints 2 to 9

Correct Answer : Option (B) :   Prints 1 to 9

53 .
Which of the following is the correct output for the C#.NET program given below?
int i = 20 ;
for( ; ; )
{
    Console.Write(i + " "); 
    if (i >= -10)
        i -= 4; 
    else 
        break;
}
A)
20 16 12 8 4 0
B)
16 12 8 4 0
C)
20 16 12 84 0 -4 -8
D)
20 16 12 8 4 0 -4 -8 -12

Correct Answer : Option (D) :   20 16 12 8 4 0 -4 -8 -12

A)
*
B)
?:
C)
as
D)
is

Correct Answer : Option (C) :   as

A)
Output parameters
B)
Value parameters
C)
Reference parameters
D)
None of the Above.

Correct Answer : Option (B) :   Value parameters

A)
Rank
B)
Length
C)
LongLength
D)
None of the Above.

Correct Answer : Option (A) :   Rank

A)
undef
B)
region
C)
endregion
D)
define

Correct Answer : Option (D) :   define

A)
line
B)
error
C)
region
D)
warning

Correct Answer : Option (D) :   warning

59 .
Which of the following C# statements is correct?
A)
C# always supports an implicit fall through from one case label to another.
B)
It is not possible to extend the if statement to handle multiple conditions using the else-if arrangement.
C)
The if statement selects a statement for execution based on the value of a Boolean expression.
D)
A jump statement such as a break is required after each case block excluding the last block if it is a default statement.

Correct Answer : Option (C) :   The if statement selects a statement for execution based on the value of a Boolean expression.

60 .
What will be the output of the C#.NET code snippet given below?
int val;
for (val = -5; val <= 5; val++)
{
    switch (val)
    {
        case 0:
            Console.Write ("India"); 
            break;
    }
    
    if (val > 0)
        Console.Write ("B"); 
    else if (val < 0)
        Console.Write ("X");
}
A)
XXXXXIndia
B)
XXXXXIndiaBBBBB
C)
IndiaBBBBB
D)
BBBBBIndiaXXXXX

Correct Answer : Option (B) :   XXXXXIndiaBBBBB

A)
pi = 6.28F
B)
#define a 6.28F
C)
const float pi = 6.28F
D)
None of the Above

Correct Answer : Option (C) :   const float pi = 6.28F

A)
DCBA
B)
ABCD
C)
0 * ABCD
D)
Depends on big endian or little endian architecture

Correct Answer : Option (D) :   Depends on big endian or little endian architecture

63 .
The C#.NET code snippet given below generates ____ numbers series as output?
int i = 1, j = 1, val;
while (i < 25)
{
    Console.Write(j + " ");
    val = i + j;
    j = i;
    i = val;
}
A)
Fibonacci
B)
Prime
C)
Odd
D)
Palindrome

Correct Answer : Option (A) :   Fibonacci

64 .
Which of the following statements are correct about the C#.NET code snippet given below?
if (age > 18 && no < 11)
    a = 25;
1. The condition no < 11 will be evaluated only if age > 18 evaluates to True.
2. The statement a = 25 will get executed if any one condition is True.
3. The condition no < 11 will be evaluated only if age > 18 evaluates to False.
4. The statement a = 25 will get executed if both the conditions are True.
5. && is known as a short circuiting logical operator.
A)
1, 3
B)
1, 4, 5
C)
2, 5
D)
3, 4, 5

Correct Answer : Option (B) :   1, 4, 5

A)
8 bit
B)
16 bit
C)
32 bit
D)
64 bit

Correct Answer : Option (B) :   16 bit

66 .
What will be the output of the C#.NET code snippet given below?
int i = 2, j = i;
if (Convert.ToBoolean((i | j & 5) & (j - 25 * 1)))
    Console.WriteLine(1); 
else
    Console.WriteLine(0);
A)
B)
1
C)
Compile Error
D)
Run time Error

Correct Answer : Option (A) :   0

67 .
What will be the output of the code snippet given below?
int i;
for(i = 0; i<=10; i++)
{
    if(i == 4)
    {
        Console.Write(i + " "); continue;
    }
    else if (i != 4)
        Console.Write(i + " "); else
    break;
}
A)
1 2 3 4
B)
4 5 6 7 8 9 10
C)
1 2 3 4 5 6 7 8 9 10
D)
0 1 2 3 4 5 6 7 8 9 10

Correct Answer : Option (D) :   0 1 2 3 4 5 6 7 8 9 10

68 .
Which of the following statements is correct about the C#.NET code snippet given below?
int i, j, id = 0; switch (id)
{ 
    case i:
        Console.WriteLine("I am in Case i");
        break; 
    
    case j:
        Console.WriteLine("I am in Case j");
        break;
}
A)
The code snippet prints the result as "I am in Case i".
B)
The code snippet prints the result as "I am in Case j".
C)
Compiler will report an error since there is no default case in the switch case statement.
D)
The compiler will report case i and case j as errors since variables cannot be used in cases.

Correct Answer : Option (D) :   The compiler will report case i and case j as errors since variables cannot be used in cases.

69 .
Which of the following will be the correct output for the C#.NET program given below?
namespace FreeTimeLearnConsoleApplication
{ 
    class SampleProgram
    {
        static void Main(string[] args)
        { 
            int num = 1;
            funcv(num); 
            Console.Write(num + ", "); 
            funcr(ref num); 
            Console.Write(num + ", ");
        }
        static void funcv(int num)
        { 
            num = num + 10; Console.Write(num + ", ");
        }
        static void funcr (ref int num)
        { 
            num = num + 10; Console.Write(num + ", ");
        } 
    } 
}
A)
1, 1, 1, 1,
B)
11, 11, 11, 11,
C)
11, 1, 11, 11,
D)
11, 11, 21, 21,

Correct Answer : Option (C) :   11, 1, 11, 11,

70 .
What will be the output of the C#.NET code snippet given below?
namespace FreeTimeLearnConsoleApplication
{ 
    class SampleProgram
    { 
        static void Main(string[] args)
        { 
            int[]arr = newint[]{ 1, 2, 3, 4, 5 }; 
            fun(ref arr);
        }
        static void fun(ref int[] a)
        { 
            for (int i = 0; i < a.Length; i++)
            { 
                a[i] = a[i] * 5; 
                Console.Write(a[ i ] + " "); 
            } 
        } 
    } 
}
A)
1 2 3 4 5
B)
5 10 15 20 25
C)
6 12 18 24 30
D)
5 25 125 625 3125

Correct Answer : Option (B) :   5 10 15 20 25

A)
Compare( )
B)
Copy( )
C)
ConCat( )
D)
Compare To()

Correct Answer : Option (A) :   Compare()

A)
Used to initialize multi line strings
B)
To embed a quotation mark by using double quotation marks inside a verbatim string
C)
Convenience and better readability of strings when string text consist of backlash characters
D)
All of the Above

Correct Answer : Option (D) :   All of the Above

A)
To create string on stack
B)
To overcome problem of stackoverflow
C)
To reduce size of string
D)
None of the Above

Correct Answer : Option (C) :   To reduce size of string

74 .
Which of the following will be the correct output for the C#.NET program given below?
namespace FreeTimeLearnConsoleApplication
{ 
    class SampleProgram
    { 
        static void Main(string[] args)
        {
            int a = 5; 
            int s = 0, c = 0;
            Proc(a, ref s, ref c);
            Console.WriteLine(s + " " + c);
        }
        static void Proc(int x, ref int ss, ref int cc)
        {
            ss = x * x;
            cc = x * x * x;
        } 
    } 
}
A)
0 0
B)
25 25
C)
25 125
D)
125 125

Correct Answer : Option (C) :   25 125

75 .
Which of the following statements are correct about functions used in C#.NET?
 
1. Function definitions cannot be nested.
2. Functions can be called recursively.
3. If we do not return a value from a function then a value -1 gets returned.
4. To return the control from middle of a function exit function should be used.
5. Function calls can be nested.
A)
2, 3
B)
1, 2, 5
C)
2, 3, 5
D)
None of the Above

Correct Answer : Option (B) :   1, 2, 5

A)
Entrypoint
B)
Function
C)
Subroutine
D)
namespace

Correct Answer : Option (A) :   Entrypoint

A)
True
B)
False
C)
None of the Above
D)
--

Correct Answer : Option (A) :   True

78 .
What will be the output of the C#.NET code snippet given below?
namespace FreeTimeLearnConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            int i = 5;
            int j;
            fun1(ref i);
            fun2(out j);
            Console.WriteLine(i + ", " + j);
        }
        static void funl(ref int x)
        {
            x = x * x;
        }
        static void fun2(out int x)
        {
            x = 6; 
            x = x * x; 
        }
    }
}
A)
5, 6
B)
25, 0
C)
5, 36
D)
25, 36

Correct Answer : Option (D) :   25, 36

79 .
What will be the output of the C#.NET code snippet given below?
namespace FreeTimeLearnConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            int i = 10;
            double d = 34.340;
            fun(i);
            fun(d);
        }
        static void fun(double d)
        {
            Console.WriteLine(d + " ");
        }
    }
}
A)
10 34
B)
10 34.340
C)
10 34.34
D)
10.000000 34.340000

Correct Answer : Option (C) :   10 34.34

A)
C# provides a copy constructor.
B)
A class can have more than one destructor.
C)
Destructors are used with classes as well as structures.
D)
A constructor can be used to set default values and limit instantiation.

Correct Answer : Option (D) :   A constructor can be used to set default values and limit instantiation.

81 .
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 s3 = new Sample(10, 1.2f, 2.4);
B)
Sample s1 = new Sample();
C)
Sample s1 = new Sample(10);
D)
Sample s2 = new Sample(10, 1.2f);

Correct Answer : Option (A) :   Sample s3 = new Sample(10, 1.2f, 2.4);

A)
Static constructors can use optional arguments.
B)
Overloaded constructors cannot use optional arguments.
C)
If we do not provide a constructor, then the compiler provides a zero-argument constructor.
D)
If we provide a one-argument constructor then the compiler still provides a zero-argument constructor.

Correct Answer : Option (C) :   If we do not provide a constructor, then the compiler provides a zero-argument constructor.

83 .
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)
3, 5
B)
2, 3, 4
C)
4, 5
D)
1, 3, 5

Correct Answer : Option (B) :   2, 3, 4

A)
Only once.
B)
As many times as we call it.
C)
Depends upon a Project Setting made in Visual Studio.NET.
D)
Any number of times before the object gets garbage collected.

Correct Answer : Option (A) :   Only once.

A)
Static functions are outside the class scope.
B)
Static functions are invoked using class.
C)
Static functions are invoked using objects of a class.
D)
Static functions can access static data as well as instance data.

Correct Answer : Option (B) :   Static functions are invoked using class.

86 .
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)
proc1() can initialize i as well as j.
B)
j can be initialized in proc2().
C)
i cannot be initialized in proc1().
D)
proc2() can initialize i as well as j.

Correct Answer : Option (A) :   proc1() can initialize i as well as j.

A)
A constructor cannot be overloaded.
B)
A constructor cannot access static data.
C)
A constructor cannot be declared as private.
D)
A constructor can be a static constructor.

Correct Answer : Option (D) :   A constructor can be a static constructor.

88 .
Which of the following statements are correct about the C#.NET code snippet given below?
int[ , ] intMyArr = {{7, 1, 3}, {2, 9, 6}};
1. intMyArr represents rectangular array of 2 rows and 3 columns.
2. intMyArr.GetUpperBound(1) will yield 2.
3. intMyArr.Length will yield 24.
4. intMyArr represents 1-D array of 5 integers.
5. intMyArr.GetUpperBound(0) will yield 2.
A)
1, 4
B)
2, 3
C)
1, 2
D)
2, 5

Correct Answer : Option (C) :   1, 2

A)
Array elements can be of integer type only.
B)
The default value of numeric array elements is zero.
C)
The length of an Array is the number of dimensions in the Array.
D)
The rank of an Array is the total number of elements it can contain.

Correct Answer : Option (B) :   The default value of numeric array elements is zero.

90 .
Which of the following is the correct output of the C#.NET code snippet given below?
 int[ , , ] a = new int[ 3, 2, 3 ]; 
 Console.WriteLine(a.Length);
A)
5
B)
10
C)
18
D)
20

Correct Answer : Option (C) :   18

91 .
Which of the following statements is correct about the array declaration given below?
 int[][][] intMyArr = new int[2][][];
A)
intMyArr refers to a 3-D jagged array containing 2 2-D jagged arrays.
B)
intMyArr refers to a 2-D jagged array containing 3 rows.
C)
intMyArr refers to a 3-D jagged array containing three 2-D jagged arrays.
D)
intMyArr refers to a 3-D jagged array containing 2 2-D rectangular arrays.

Correct Answer : Option (A) :   intMyArr refers to a 3-D jagged array containing 2 2-D jagged arrays.

92 .
Which of the following is the correct output of the C#.NET code snippet given below?
    int[][] a = new int[2][];
    a[0] = new int[4]{6, 1, 4, 3};
    a[1] = new int[3]{9, 2, 7}; 
    Console.WriteLine(a[1].GetUpperBound(0));
A)
2
B)
3
C)
4
D)
5

Correct Answer : Option (A) :   2

93 .
Which of the following statements is correct about the C#.NET code snippet given below?
int[] intMyArr = {11, 3, 5, 9, 4};​
 
A)
intMyArr is a reference to an array of integers.
B)
intMyArr is a reference to an object created on the stack.
C)
intMyArr is a reference to an object of System.Array Class.
D)
intMyArr is a reference to an object of a class that the compiler derives from System.Array Class.

Correct Answer : Option (D) :   intMyArr is a reference to an object of a class that the compiler derives from System.Array Class.

94 .
How many bytes will the structure variable samp occupy in memory if it is defined as shown below?
class Trial
{ 
    int i; 
    Decimal d;
}
struct Sample
{
    private int x; 
    private Single y; 
    private Trial z;
}
Sample samp = new Sample();
A)
8 bytes
B)
12 bytes
C)
16 bytes
D)
24 bytes

Correct Answer : Option (B) :   12 bytes

A)
When it goes out of scope.
B)
When no reference refers to it, it will get garbage collected.
C)
Depends upon whether it is created using new or without using new.
D)
Depends upon whether we free it's memory using free() or delete().

Correct Answer : Option (A) :   When it goes out of scope.

96 .
Which of the following statements is correct about the C#.NET code snippet given below?
struct Book
{
    private String name; 
    private int noofpages; 
    private Single price;
}
Book b = new Book();
A)
We can inherit a new structure from struct Book.
B)
The structure variable b will be created on the heap.
C)
The structure variable b will be created on the stack.
D)
When the program terminates, variable b will get garbage collected.

Correct Answer : Option (C) :   The structure variable b will be created on the stack.

97 .
Which of the following will be the correct output for the program given below?
 
namespace FreeTimeLearnConsoleApplication
{ 
    struct Sample
    {
        public int i;
    }
    class MyProgram
    { 
        static void Main(string[] args)
        {
            Sample x = new Sample();
            Sample y;
            x.i = 9;
            y = x;
            y.i = 5;
            Console.WriteLine(x.i + " " + y.i); 
        } 
    } 
}
A)
5 5
B)
5 9
C)
9 5
D)
9 9

Correct Answer : Option (C) :   9 5

98 .
Which of the following statements are correct about Structures used in C#.NET?
 
1. A Structure can be declared within a procedure.
2. Structs can implement an interface but they cannot inherit from another struct.
3. struct members cannot be declared as protected.
4. A Structure can be empty.
5. It is an error to initialize an instance field in a struct.
A)
1, 3
B)
2, 4
C)
1, 2, 4
D)
2, 3, 5

Correct Answer : Option (D) :   2, 3, 5

A)
Exception
B)
StackMemoryException
C)
OutOfMemoryException
D)
DivideByZeroException

Correct Answer : Option (B) :   StackMemoryException

A)
It occurs at run-time.
B)
It occurs during linking.
C)
It occurs during compilation.
D)
It occurs during Just-In-Time compilation.

Correct Answer : Option (A) :   It occurs at run-time.

A)
Exceptions
B)
OnError
C)
Error codes
D)
Setjump and Longjump

Correct Answer : Option (A) :   Exceptions

102 .
Which of the following statements is correct about the C#.NET program given below if a value "6" is input to it?
using System;
namespace FreeTimeLearnConsoleApplication
{
    class MyProgram
    {
        static void Main(string[] args)
        {
            int index; 
            int val = 44;
            int[] a = new int[5];
            try
            {
                Console.Write("Enter a number:");
                index = Convert.Tolnt32(Console.ReadLine());
                a[index] = val;
            }
            catch(FormatException e)
            {
                Console.Write("Bad Format");
            }
            catch(IndexOutOfRangeException e)
            {
                Console.Write("Index out of bounds");
            }
            Console.Write("Remaining program");
        }
    }
}
A)
It will output: Bad Format
B)
It will output: Index out of bounds
C)
It will output: Bad Format Remaining program
D)
It will output: Index out of bounds Remaining program

Correct Answer : Option (D) :   It will output: Index out of bounds Remaining program

A)
Division By Zero
B)
Insufficient Memory
C)
Incorrect Arithmetic Expression
D)
Arithmetic overflow or underflow

Correct Answer : Option (C) :   Incorrect Arithmetic Expression

A)
True
B)
False
C)
None of the Above
D)
--

Correct Answer : Option (B) :   False

105 .
Which of the following can be declared in an interface?
 
1. Properties
2. Methods
3. Enumerations
4. Events
5. Structures
A)
1, 3
B)
3, 5
C)
4, 5
D)
1, 2, 4

Correct Answer : Option (D) :   1, 2, 4

A)
Interfaces cannot be inherited.
B)
One class can implement only one interface.
C)
Properties can be declared inside an interface.
D)
From two base interfaces a new interface cannot be inherited.

Correct Answer : Option (C) :   Properties can be declared inside an interface.

107 .
Which of the following statements are correct about an interface used in C#.NET?
 
1. An interface can contain properties, methods and events.
2. The keyword must implement forces implementation of an interface.
3. Interfaces can be overloaded.
4. Interfaces can be implemented by a class or a struct.
5. Enhanced implementations of an interface can be developed without breaking existing code.
A)
1, 2
B)
3, 4
C)
3 only
D)
1, 4, 5

Correct Answer : Option (D) :   1, 4, 5

108 .
Which of the following can implement an interface?
 
1. Data
2. Class
3. Enum
4. Structure
5. Namespace
A)
2, 4
B)
1, 3
C)
3, 5
D)
4 only

Correct Answer : Option (A) :   2, 4

109 .
Which of the following statements is correct about the C#.NET code snippet given below?
interface IPerson
{ 
    String FirstName
    { 
        get; 
        set;
    }
    String LastName
    {
        get; 
        set;
    }
    void Print(); 
    void Stock(); 
    int Fun(); 
}
A)
The properties in the interface must have a body.
B)
Functions cannot be declared inside an interface.
C)
This is a perfectly workable interface.
D)
Properties cannot be declared inside an interface.

Correct Answer : Option (C) :   This is a perfectly workable interface.

110 .
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)
0 1
B)
92 163
C)
192 63
D)
163 92

Correct Answer : Option (D) :   163 92

A)
&
B)
<<
C)
|
D)
^

Correct Answer : Option (B) :   <<

112 .
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

Correct Answer : Option (A) :   1, 2, 3

113 .
What will be the output of the C#.NET code snippet given below?
int num = 1, z = 5;

if (!(num <= 0))
    Console.WriteLine( ++num + z++ + " " + ++z ); 
else
    Console.WriteLine( --num + z-- + " " + --z ); 
A)
5 6
B)
6 5
C)
6 6
D)
7 7

Correct Answer : Option (D) :   7 7

A)
/=
B)
\=
C)
*=
D)
%=

Correct Answer : Option (B) :   \=

115 .
What will be the output of the C#.NET code snippet given below?
int i, j = 1, k;
for (i = 0; i < 5; i++)
{
    k = j++ + ++j;
    Console.Write(k + " ");
}
A)
4 8 12 16 20
B)
2 4 6 8 10
C)
8 4 16 12 20
D)
4 8 16 32 64

Correct Answer : Option (A) :   4 8 12 16 20

116 .
What will be the output of the C#.NET code snippet given below?
int a = 10, b = 20, c = 30; 
int res = a < b ? a < c ? c : a : b; 
Console.WriteLine(res);
A)
10
B)
20
C)
30
D)
Compile Error / Syntax Error

Correct Answer : Option (C) :   30

A)
The ^ operator can be used to put ON a bit.
B)
The ^ operator can be used to put OFF a bit.
C)
The ^ operator can be used to check whether a bit is ON.
D)
The ^ operator can be used to Invert a bit.

Correct Answer : Option (D) :   The ^ operator can be used to Invert a bit.

118 .
Which of the following can be facilitated by the Inheritance mechanism?
 
1. Use the existing functionality of base class.
2. Overrride the existing functionality of base class.
3. Implement new functionality in the derived class.
4. Implement polymorphic behaviour.
5. Implement containership.
A)
3, 4
B)
3, 5
C)
2, 4, 5
D)
1, 2, 3

Correct Answer : Option (D) :   1, 2, 3

A)
Containership
B)
Inheritance
C)
Polymorphism
D)
Encapsulation

Correct Answer : Option (A) :   Containership

120 .
In an inheritance chain which of the following members of base class are accessible to the derived class members?
 
1. static
2. protected
3. private
4. shared
5. public
A)
1, 3
B)
2, 5
C)
3, 4
D)
4, 5

Correct Answer : Option (B) :   2, 5

A)
Encapsulation
B)
Polymorphism
C)
Inheritance
D)
Containership

Correct Answer : Option (C) :   Inheritance

A)
Declare the class as shadows.
B)
Declare the class as overloads.
C)
Declare the class as override.
D)
Declare the class as sealed.

Correct Answer : Option (D) :   Declare the class as sealed.


Explanation : C#.NET allows sealed attribute to be used as a part of class statement. Classes declared with sealed keyword cannot be used as based class for other classes. Most important reason to do this world be to prevent behavior of a class to be changed in any way.

123 .
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)
2, 5
B)
2, 3, 5
C)
3, 4
D)
1, 2, 4

Correct Answer : Option (B) :   2, 3, 5

124 .
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)
Nagpur
B)
Mumbai
C)
Nagpur Mumbai
D)
NagpurMumbai

Correct Answer : Option (D) :   NagpurMumbai

A)
s1.Equals(s2)
B)
s1 is s2
C)
s1 == s2
D)
strcmp(s1, s2)

Correct Answer : Option (A) :   s1.Equals(s2)

A)
A number CANNOT be represented in the form of a String.
B)
A String has a zero-based index.
C)
Methods of the String class can be used to modify the string.
D)
A String is mutable because it can be modified once it has been created.

Correct Answer : Option (B) :   A String has a zero-based index.

127 .
Which of the following statements is correct about the C#.NET code snippet given below?
int a = 10; 
int b = 20; 
int c = 30;
enum color: byte
{
    red = a, 
    green = b,
    blue = c 
}
A)
Variables can be assigned only to the first enum element.
B)
Variables can be assigned to any one of the enum elements.
C)
Variables cannot be assigned to enum elements.
D)
Values assigned to enum elements must always be successive values.

Correct Answer : Option (C) :   Variables cannot be assigned to enum elements.

128 .
Which of the following statements is correct about the C#.NET code snippet given below?
enum per
{
    married, 
    unmarried, 
    divorced, 
    spinster
}
per.married = 10; 
Console.WriteLine(per.unmarried);
A)
The program will output a value 2.
B)
The program will output a value 1.
C)
The program will output a value 11.
D)
The program will report an error since an enum element cannot be assigned a value outside the enum declaration.

Correct Answer : Option (D) :   The program will report an error since an enum element cannot be assigned a value outside the enum declaration.

129 .
Which of the following is the correct output for the C#.NET code snippet given below?
enum color: int
{ 
    red,
    green, 
    blue = 5, 
    cyan,
    magenta = 10, 
    yellow 
}
Console.Write( (int) color.green + ", " ); 
Console.Write( (int) color.yellow );
A)
1, 5
B)
2, 6
C)
1, 11
D)
2, 11

Correct Answer : Option (C) :   1, 11

A)
int
B)
float
C)
byte
D)
short

Correct Answer : Option (B) :   float

A)
sealed
B)
extends
C)
inherits
D)
inheritable

Correct Answer : Option (A) :   sealed

A)
new
B)
base
C)
override
D)
overloads

Correct Answer : Option (A) :   new

A)
opoverload
B)
udoperator
C)
operator
D)
operatoroverload

Correct Answer : Option (C) :   operator

A)
override
B)
virtual
C)
overloads
D)
overridable

Correct Answer : Option (A) :   override

A)
new
B)
virtual
C)
overloads
D)
overrides

Correct Answer : Option (B) :   virtual

136 .
Which of the following are necessary for Run-time Polymorphism?
 
1. The overridden base method must be virtual, abstract or override.
2. Both the override method and the virtual method must have the same access level modifier.
3. An override declaration can change the accessibility of the virtual method.
4. An abstract inherited property cannot be overridden in a derived class.
5. An abstract method is implicitly a virtual method.
A)
1, 3
B)
4 only
C)
2, 3, 4
D)
1, 2, 5

Correct Answer : Option (D) :   1, 2, 5

A)
Design-time
B)
Compile-time
C)
Linking-time
D)
Run-time

Correct Answer : Option (D) :   Run-time

138 .
Which of the following statements are correct about inspecting an attribute in C#.NET?
 
1. An attribute can be inspected at link-time.
2. An attribute can be inspected at compile-time.
3. An attribute can be inspected at run-time.
4. An attribute can be inspected at design-time.
A)
1, 2
B)
3, 4
C)
1, 3, 4
D)
All of the Above

Correct Answer : Option (A) :   1, 2

A)
It contains class-level attributes.
B)
It contains method-level attributes.
C)
It contains assembly-level attributes.
D)
It contains structure-level attributes.

Correct Answer : Option (C) :   It contains assembly-level attributes.

A)
Linker
B)
ASP.NET Runtime
C)
Visual Studio.NET
D)
Language compilers

Correct Answer : Option (A) :   Linker