You are on page 1of 7

1) Which of The Following Statements Are Correct for The Given Code Snippet:

shape obj;
obj = new shape();
a) Creates an object of class shape.
b) To create an object of type shape on the heap or stack depending on its size.
c) Create a reference obj of the class shape and an object of type shape on the
heap.
d) Create an object of type shape on the stack.

2) What Will Be the Output of The Following Code Snippet?


using System;
class sample
{
public static void first ()
{
Console.WriteLine("first method");
}
public void second()
{
first();
Console.WriteLine("second method");
}
public void second(int i)
{
Console.WriteLine(i);
second();
}
}
class program
{
public static void Main()
{
sample obj = new sample();
sample.first();
obj.second(10);
}
}
a) second method
10
second method
first method
b) first method
10
first method
second method
c) first method
10
d) second method
10
first method.

3) Which Of The Following Statements Correctly Tell The Differences Between ‘=’
And ‘==’ In C#?
a) ‘==’ operator is used to assign values from one variable to another variable
‘=’ operator is used to compare value between two variables.
b) ‘=’ operator is used to assign values from one variable to another variable
‘==’ operator is used to compare value between two variables
c) No difference between both operators
d) None of the mentioned

4) Which of the following is an 8-byte Integer?


a) Char

b) Long

c) Short

d) Byte

e) Integer

5) Which of the following is NOT an Integer?


a) Char

b) Byte

c) Integer

d) Short

e) Long

6) Which of the following are value types?


Integer
Array
Single
String
Long
a) 1, 2, 5
b) 1, 3, 5

c) 2, 4

d) 3, 5

7) What is the size of a Decimal?


a) 4 byte

b) 8 byte

c) 16 byte

d) 32 byte

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

b)
b) Only 1, 2 and 4

c) 1, 2, 3, 4

d) Only 4 and 5

e) Only 3 and 4

9) 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 1 to 9

b) Prints 0 to 8

c) Prints 2 to 8
d) Prints 2 to 9

e) Compile error at label:.

10) Which of the following statements is correct?


a) It is not possible to extend the if statement to handle multiple conditions using the else-
if arrangement.

b) The switch statement can include any number of case instances with two case statements
having the same value.

c) A jump statement such as a break is required after each case block excluding the last
block if it is a default statement.

d) The if statement selects a statement for execution based on the value of a Boolean
expression.

e) C# always supports an implicit fall through from one case label to another.

11) 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

12) 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
13) 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.

14) 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;
}
}
e) Sample s1 = new Sample();

f) Sample s1 = new Sample(10);

g) Sample s2 = new Sample(10, 1.2f);

h) Sample s3 = new Sample(10, 1.2f, 2.4);

i) Sample s1 = new Sample(, , 2.5);

15) Which of the following statements are correct about static functions?
Static functions can access only static data.
Static functions cannot call instance functions.
It is necessary to initialize static data.
Instance functions can call static functions and access static data.
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
16) In C#.NET if we do not catch the exception thrown at runtime then which of the
following will catch it?
a) Compiler

b) CLR

c) Linker

d) Loader

e) Operating system
17) Which of the following statements are correct?

We can assign values of any type to variables of type object.


When a variable of a value type is converted to object, it is said to be unboxed.
When a variable of type object is converted to a value type, it is said to be boxed.
Boolean variable cannot have a value of null.
When a value type is boxed, an entirely new object must be allocated and constructed.
a) 2, 5

b) 1, 5

c) 3, 4

d) 2, 3
18) Which of the following statements are correct about data types?
Each value type has an implicit default constructor that initializes the default value of that type.
It is possible for a value type to contain the null value.
All value types are derived implicitly from System.ValueType class.
It is not essential that local variables in C# must be initialized before being used.
Variables of reference types referred to as objects and store references to the actual data.
a) 1, 3, 5

b) 2, 4

c) 3, 5

d) 2, 3, 4
19) Which of the following are the correct way to initialise the variables i and j to a
value 10 each?
int i = 10; int j = 10;
int i, j;
i = 10 : j = 10;
int i = 10, j = 10;
int i, j = 10;
int i = j = 10;
a) 2, 4

b) 1, 3

c) 3, 5

d) 4, 5
20) Which of the following statement correctly assigns a value 33 to a variable c?
byte a = 11, b = 22, c;
e) c = (byte) (a + b);

f) c = (byte) a + (byte) b;

g) c = (int) a + (int) b;

h) c = (int)(a + b);

i) c = a + b;

You might also like