C# Test 6

Which of the following is the correct ways to set a value 3.14 in a variable pi such that it cannot be modified?

Which of the following statement correctly assigns a value 33 to a variable c?

byte a = 11, b = 22, c;

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.


Which of the following statements is correct about Bitwise | operator used in C#.NET?

A function can be used in an expression, whereas a subroutine cannot be.

Can static procedures access instance data?

Which of the following statements is correct?

Which of the following statements should be added to the subroutine fun( ) if the C#.NET code snippet given below is to output 9 13?

class BaseClass
{
protected int i = 13;
}
class Derived: BaseClass
{
int i = 9;
public void fun()
{
// [*** Add statement here ***]
}
}

Which of the following statements are correct about the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
class index
{
protected int count;
public index()
{
count = 0;
}
}
class index1: index
{
public void increment()
{
count = count +1;
}
}
class MyProgram
{
static void Main(string[] args)
{
index1 i = new index1();
i.increment();
}
}
}

1. count should be declared as public if it is to become available in the inheritance chain.
2. count should be declared as protected if it is to become available in the inheritance chain.
3. While constructing an object referred to by i firstly constructor of index class will be called followed by constructor of index1 class.
4. Constructor of index class does not get inherited in index1 class.
5. count should be declared as Friend if it is to become available in the inheritance chain.

When would a structure variable get destroyed?

Which of the following statements are correct about the structure declaration given below?

struct Book
{
private String name;
protected int totalpages;
public Single price;
public void Showdata()
{
Console.WriteLine(name + " " + totalpages + " " + price);
}
Book()
{
name = " ";
totalpages = 0;
price = 0.0f;
}
}
Book b = new Book();

1. We cannot declare the access modifier of totalpages as protected.
2. We cannot declare the access modifier of name as private.
3. We cannot define a zero-argument constructor inside a structure.
4. We cannot declare the access modifier of price as public.
5. We can define a Showdata() method inside a structure.

Which of the following is the necessary condition for implementing delegates?

Which of the following statements are correct about a delegate?
1. Inheritance is a prerequisite for using delegates.
2. Delegates are type-safe.
3. Delegates provide wrappers for function pointers.
4. The declaration of a delegate must match the signature of the method that we intend to call using it.
5. Functions called using delegates are always late-bound.


Attributes can be applied to
1. Method
2. Class
3. Assembly
4. Namespace
5. Enum


Which of the following statements are valid about generics in .NET Framework?
1. Generics is a language feature.
2. We can create a generic class, however, we cannot create a generic interface in C#.NET.
3. Generics delegates are not allowed in C#.NET.
4. Generics are useful in collection classes in .NET framework.
5. None of the above


Which of the following statements are correct about an enum used inC#.NET?
1. To use the keyword enum, we should either use [enum] or System.Enum.
2. enum is a keyword.
3. Enum is class declared in System.Type namespace.
4. Enum is a class declared in the current project's root namespace.
5. Enum is a class declared in System namespace.


Which of the following statements are correct about enum used in C#.NET?
1. Every enum is derived from an Object class.
2. Every enum is a value type.
3. There does not exist a way to print an element of an enum as a string.
4. Every enum is a reference type.
5. The default underlying datatype of an enum is int.


Which of the following statements are correct about the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
(
class Sample
{
private enum color : int
{
red,
green,
blue
}
public void fun()
{
Console.WriteLine(color.red);
}
}
class Program
{
static void Main(string[ ] args)
{
// Use enum color here
}
}
}

1. To define a variable of type enum color in Main(), we should use the statement, color c; .
2. enum color being private it cannot be used in Main().
3. We must declare enum color as public to be able to use it outside the class Sample.
4. To define a variable of type enum color in Main(), we should use the statement, Sample.color c; .
5. We must declare private enum color outside the class to be able to use it in Main().

Which of the following statements is correct about the using statement used in C#.NET?

Schreibe einen Kommentar