Tes2 Test2
Tes2 Test2
What will be the output of the C#.NET code snippet given below?
namespace IndiabixConsoleApplication
class Sample
Console.WriteLine("Bix1 method");
fun1();
Console.WriteLine("Bix2 method");
Console.WriteLine(i);
fun2();
class MyProgram
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
2. Which of the following statements are correct about the C#.NET code snippet given below? if
(age > 18 || no < 11) a = 25;
B. The statement will get evaluated any one one of the two conditions is .
C. The statement will get evaluated only both the conditions are .
D. All of these
Explanation:-
A. Properties
B. Methods
C. Events
5. If Sample class has a Length property with get accessor then which of the following statements will
work correctly?
A.
m.Length = 10;
B.
int l;
l = m.Length;
D.
Sample.Length = 20;
E.
Console.WriteLine(Sample.Length);
6.An Account class has a property called accountNo and acc is a reference to a bank object and we want
the C#.NET code snippet given below to work. Which of the following options will ensure this
functionality?
acc.accountNo = 10;
Console.WriteLine(acc.accountNo);
A.
class Student
set
if (index < 5)
scores[index] = value;
else
Console.WriteLine("Invalid Index");
B.
class Student
get
{
if (index < 5)
else
set
if (index < 5)
else
Console.WriteLine("Invalid Index");
C.
class Student
get
if (index < 5)
else
{
Console.WriteLine("Invalid Index");
return 0;
D.
class Student
get
if (index < 5)
else
Console.WriteLine("Invalid Index");
set
if (index < 5)
else
{
Console.WriteLine("Invalid Index");
return 0;
C. Properties of a class are actually methods that work like data members.
9. Which of the following is the correct way to implement a read only property Length in a Sample class?
A.
class Sample
int len;
get
return len;
}
}
B.
class Sample
get
return Length;
C.
class Sample
int len;
get
return len;
set
len = value;
}
D.
class Sample
int len;
Readonly get
return len;
10. Which of the folowing does an indexer allow to index in the same way as an array?
1: A class
2:A property
3:A struct
4:A function
5:An interface
A. 1, 3, 5
B. 2, 4
C. 3, 5
D. 3, 4, 5
11. An Employee class has a property called age and emp is reference to a Employee object and we want
the statement Console.WriteLine(emp.age) to fail. Which of the following options will ensure this
functionality?
12. Which of the following statements are correct about data types?
1:If the integer literal exceeds the range of byte, a compilation error will occur.
2:We cannot implicitly convert non-literal numeric types of larger storage size to byte.
A. 1, 3, 5
B. 2, 4
C. 3, 5
D. 1, 2, 5
13. Which of the following is an 8-byte Integer?
A. Char
B. Long
C. Short
D. Byte
E. Integer
A. Char
B. Byte
C. Integer
D. Short
E. Long
1: Integer
2: Array
3: Single
4: String
5: Long
A. 1, 2, 5
B. 1, 3, 5
C. 2, 4
D. 3, 5
A. Short
B. Integer
C. Long
D. Byte
E. Single
A. 4 byte
B. 8 byte
C. 16 byte
D. 32 byte
20. What will be the output of the following code snippet when it is executed?
int x = 1;
float y = 1:1f;
short z = 1;
A. 0.1
B. 1:0
C. 1:1
D. 11
21Which of the following statements is correct about the C#.NET code snippet given below?
short s1 = 20;
short s2 = 400;
int a;
a = s1 * s2;
C. During arithmetic if the result exceeds the high or low value of the range the value wraps
around till the other side of the range.
E. An overflow error will be reported since the result of the multiplication exceeds the range of a
Short Integer.
A. 8 Bytes
B. 4 Bytes
C. 10 Bytes
D. 16 Bytes
5: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
24 Which of the following is the correct ways to set a value 3:14 in a variable pi such that it cannot be
modified?
A. float pi = 3:14F;
B. #define pi 3:14F;
E. pi = 3:14F;
25. Which of the following statements are correct about data types?
1:Each value type has an implicit default constructor that initializes the default value of that type.
4: It is not essential that local variables in C# must be initialized before being used.
5: 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
26. Which of the following are the correct way to initialise the variables i and j to a value 10 each?
int i, j;
i = 10 : j = 10;
int i, j = 10;
int i = j = 10;
A. 2, 4
B. 1, 3
C. 3, 5
D. 4, 5
A. c = (byte) (a + b);
B. c = (byte) a + (byte) b;
C. c = (int) a + (int) b;
D. c = (int)(a + b);
E. c = a + b;
28. Which of the following statements are correct about datatypes in C#.NET?
4:Mapping of every value type to a type in Common Type System facilitates Interoperability in C#.NET.
A. 1, 3
B. 2, 5
C. 1, 4
D. 3, 4
29. Which of the following is the correct default value of a Boolean type?
A. 0
B. 1
C. True
D. False
E. -1
30. 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
31. 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);
temp = (byte)(b1^b2);
Console.WriteLine(temp);
A. 163 92
B. 92 163
C. 192 63
D. 01
A. **
B. +
C. /
D. %
E. *
1: >=
2: !=
3: Not
4: <=
5: <>=
A. 1, 3
B. 2, 4
C. 3, 5
D. 4, 5
E. None of these
A. &
B. |
C. <<
D. ^
E. ~
35. Which of the following statements is correct about the C#.NET code snippet given below?
int d;
36. 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. 60
D. 61
E. 6.5 6.5
37. Which of the following statements are correct about the Bitwise & operator used in C#.NET?
A. 1, 2, 4
B. 2, 3, 5
C. 3, 4
D. 3, 4, 5
E. None of these
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
39. 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)
B.
if ((n&8) == 8)
C.
if ((n ! 8) == 8)
D.
if ((n ^ 8) == 8)
E.
if ((n ~ 8) == 8)
40. What will be the output of the C#.NET code snippet given below?
int num = 1, z = 5;
else
A. 56
B. 65
C. 66
D. 77
41.Suppose n is a variable of the type Byte and we wish to put OFF its fourth bit (from right) without
disturbing any other bits. Which of the following statements will do this correctly?
A. n = n && HF7
B. n = n & 16
C. n = n & 0xF7
D. n = n & HexF7
E. n=n&8
42. What will be the output of the C#.NET code snippet given below?
byte b1 = 0xAB;
byte b2 = 0x99;
byte temp;
temp = (byte)~b2;
Console.WriteLine(temp);
A. 102 1 38
B. 108 0 32
C. 102 0 38
D. 101
43. Which of the following statements is correct about Bitwise | operator used in C#.NET?
A. \=
B. /=
C. *=
D. +=
E. %=
45. What will be the output of the C#.NET code snippet given below?
int i, j = 1, k;
k = j++ + ++j;
A. 8 4 16 12 20
B. 4 8 12 16 20
C. 4 8 16 32 64
D. 2 4 6 8 10
46. What will be the output of the C#.NET code snippet given below?
Console.WriteLine(res);
A. 10
B. 20
C. 30
47.Which of the following statements are correct about the following code snippet?
int a = 10;
int b = 20;
bool c;
A. 1, 3
B. 2, 4
C. 4, 5
D. 1, 4
E. None of these
48. Which of the following statements is correct about Bitwise ^ operator used in C#.NET?
1:The conditional operator (?:) returns one of two values depending on the value of a Boolean
expression.
2:The as operator in C#.NET is used to perform conversions between compatible reference types.
3:The &* operator is also used to declare pointer types and to dereference pointers.
5:In addition to being used to specify the order of operations in an expression, brackets [ ] are used to
specify casts or type conversions.
A. 1, 2, 4
B. 2, 3, 5
C. 3, 4, 5
D. 1, 3, 5
E. None of these
50. Which of the following will be the correct output for the C#.NET program given below?
namespace IndiabixConsoleApplication
class Sample
int i;
Single j;
public void SetData(int i, Single j)
i = i;
j = j;
class MyProgram
s1:SetData(10, 5:4f);
s1:Display();
A. 00
B. 10 5:4
C. 10 5:400000
D. 10 5
50. The this reference gets created when a member function (non-shared) of a class is called.
A. True
B. False
51. Which of the following statements is correct about the C#.NET code snippet given below?
namespace IndiabixConsoleApplication
class Sample
arr[i] = val;
class MyProgram
s.index = 20;
Sample.fun(1, 5);
s.fun(1, 5);
}
A. s.index = 20 will report an error since index is public.
D. The call Sample.fun(1, 5) cannot work since fun() is not a shared function.