C# Test 9

Which of the following statements is correct about Managed Code?
Which of the following is the root of the .NET type hierarchy?
Which of the following code snippets are the correct way to determine whether a is Odd or Even?
1.
int a;
String res;
if (a % 2 == 0)
res = "Even";
else
res = "Odd";

2.
int a; 
String res;
if (a Mod 2 == 0)
res = "Even";
else
res = "Odd";

3.
int a;
Console.WriteLine(a Mod 2 == 0 ? "Even": "Odd");

4.
int a; 
String res;
a % 2 == 0 ? res = "Even" : res = "Odd";
Console.WriteLine(res);
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 18 evaluates to False.
2. The condition no 18 evaluates to True.
3. The statement a = 25 will get evaluated if any one one of the two conditions is True.
4. || is known as a short circuiting logical operator.
5. The statement a = 25 will get evaluated only if both the conditions are True.

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?
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.Write(temp + " ");
temp = (byte)(b1 <> 2);
Console.WriteLine(temp);
Which of the following statements is correct about Bitwise ^ operator used in C#.NET?
Which of the following statements is correct about the C#.NET code snippet given below?
class Student s1, s2; // Here 'Student' is a user-defined class.
s1 = new Student();
s2 = new Student();
Which of the following statements are correct about the this reference?
1. this reference can be modified in the instance member function of a class.
2. Static functions of a class never receive the this reference.
3. Instance member functions of a class always receive a this reference.
4. this reference continues to exist even after control returns from an instance member function.
5. While calling an instance member function we are not required to pass the this reference explicitly.

Which of the following statements are correct about objects of a user-defined class called Sample?
1. All objects of Sample class will always have exactly same data.
2. Objects of Sample class may have same or different data.
3. Whether objects of Sample class will have same or different data depends upon a Project Setting made in Visual Studio.NET.
4. Conceptually, each object of Sample class will have instance data and instance member functions of the Sample class.
5. All objects of Sample class will share one copy of member functions.

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();
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();
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.

In a HashTable Key cannot be null, but Value can be.
Which of the following can be declared as a virtual in a class?
1. Methods
2. Properties
3. Events
4. Fields
5. Static fields

Which of the following statements is correct about the C#.NET code snippet given below?
interface IMyInterface 
{
void fun1();
void fun2();
}
class MyClass: IMyInterface
{
private int i;
void IMyInterface.fun1()
{
// Some code
}
}
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();
}
Schreibe einen Kommentar