Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Top%2030%20C

Top%2030%20C
1. Which of the following is the correct way to create an object of the class Sample?
1.Sample s = new Sample();
2.Sample s;
3.Sample s; s = new Sample();
4.s = new Sample();
  1, 3
  2, 4
  1, 2, 3
  4, 5
2. 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;
}
public void Display()
{
Console.WriteLine(i + " " + j);
}
}
class MyProgram
{
static void Main(string[ ] args)
{
Sample s1 = new Sample();
s1.SetData(10, 5.4f);
s1.Display();
}
}
}
  0 0
  10 5.4
  10 5.400000
  10 5
3. The this reference gets created when a member function (non-shared) of a class is called?
  True
  False
4. Which of the following statements is correct about the C#.NET code snippet given below?

int i;
int j = new int();
i = 10;
j = 20;
String str;
str = i.ToString();
str = j.ToString();
  This is a perfectly workable code snippet.
  Since int is a primitive, we cannot use new with it.
  Since an int is a primitive, we cannot call the method ToString() using it.
  I will get created on stack, whereas j will get created on heap.
5. 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.
  1, 2
  2, 3
  2, 5
  1, 4
6. In a HashTable Key cannot be null, but Value can be?
  True
  False
7. Which of the following is the correct way to find out the number of elements currently present in an ArrayList Collection called arr?
  arr.Count
  arr.GrowSize
  arr.MaxIndex
  arr.Capacity
8. Which of the following statements is correct?
  A constructor can be used to set default values and limit instantiation.
  C# provides a copy constructor.
  Destructors are used with classes as well as structures.
  A class can have more than one destructor.
9. Is it possible to invoke Garbage Collector explicitly?
  Yes
  No
10. Is it possible for you to prevent an object from being created by using zero argument constructor?
  Yes
  No
11. A function returns a value, whereas a subroutine cannot return a value.
  True
  False
12. How many values is a function capable of returning?
  1
  0
  Depends upon how many params arguments does it use.
  Any number of values.
13. Creating empty structures is allowed in C#.NET?
  True
  False
14. Which of the following statements is correct about the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
class Sample
{
public int index;
public int[] arr = new int[10];

public void fun(int i, int val)
{
arr[i] = val;
}
}

class MyProgram
{
static void Main(string[] args)
{
Sample s = new Sample();
s.index = 20;
Sample.fun(1, 5);
s.fun(1, 5);
}
}
}
  s.index = 20 will report an error since index is public.
  The call s.fun(1, 5) will work correctly.
  Sample.fun(1, 5) will set a value 5 in arr[ 1 ].
  The call Sample.fun(1, 5) cannot work since fun() is not a shared function.
15. Which of the following statements are correct about the C#.NET code snippet given below?

sample c;
c = new sample();
1.It will create an object called sample.
2.It will create a nameless object of the type sample.
3.It will create an object of the type sample on the stack.
4.It will create a reference c on the stack and an object of the type sample on the heap.
5.It will create an object of the type sample either on the heap or on the stack depending on the size of the object.
  1, 3
  2, 4
  3, 5
  4, 5
16. 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 thethis reference explicitly.
  1, 4
  2, 3, 5
  3, 4
  2, 5
17. 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)
{
this.i = i;
this.j = j;
}
public void Display()
{
Console.WriteLine(i + " " + j);
}
}
class MyProgram
{
static void Main(string[ ] args)
{
Sample s1 = new Sample();
s1.SetData(36, 5.4f);
s1.Display();
}
}
}
  0 0.0
  36 5.4
  36 5.400000
  36 5
18. Which of the following statements are correct about the C#.NET code snippet given below?

int[] a = {11, 3, 5, 9, 4};
1.The array elements are created on the stack.
2.Refernce a is created on the stack.
3.The array elements are created on the heap.
4.On declaring the array a new array class is created which is derived fromSystem.Array Class.
5.Whether the array elements are stored in the stack or heap depends upon the size of the array.
  1, 2
  2, 3, 4
  2, 3, 5
  4, 5
19. Creating empty structures is allowed in C#.NET?
  True
  False
20. Which of the following statements are correct about the C#.NET code snippet given below?

int[][]intMyArr = new int[2][];
intMyArr[0] = new int[4]{6, 1, 4, 3};
intMyArr[1] = new int[3]{9, 2, 7};
  The two rows of the jagged array intMyArr are stored in adjacent memory locations.
  intMyArr[0] refers to the zeroth 1-D array and intMyArr[1] refers to the first 1-D array.
  intMyArr refers to intMyArr[0] and intMyArr[1].
  intMyArr refers to intMyArr[1] and intMyArr[2].
21. Which of the following statements are correct about an ArrayList collection that implements the IEnumerable interface?
1.The ArrayList class contains an inner class that implements theIEnumerator interface.
2.An ArrayList Collection cannot be accessed simultaneously by different threads.
3.The inner class of ArrayList can access ArrayList class's members.
4.To access members of ArrayList from the inner class, it is necessary to pass ArrayList class's reference to it.
5.Enumerator's of ArrayList Collection can manipulate the array.
  1 and 2 only
  1 and 3 and 4 only
  2 and 5 only
  All of the above
22. In which of the following collections is the Input/Output index-based?
1.Stack
2.Queue
3.BitArray
4.ArrayList
5.HashTable
  1 and 2 only
  3 and 4 only
  5 only
  1, 2 and 5 only
23. Which of the following is an ordered collection class?
1.Map
2.Stack
3.Queue
4.BitArray
5.HashTable
  1 only
  2 and 3 only
  4 and 5 only
  All of the above
24. Can static procedures access instance data?
  Yes
  No
25. How many times can a constructor be called during lifetime of the object?
  As many times as we call it.
  Only once.
  Depends upon a Project Setting made in Visual Studio.NET.
  Any number of times before the object gets garbage collected.
26. Which of the following statements is correct?
  There is one garbage collector per program running in memory.
  There is one common garbage collector for all programs.
  An object is destroyed by the garbage collector when only one reference refers to it.
  We have to specifically run the garbage collector after executing Visual Studio.NET.
27. Which of the following statements are correct?
1.Data members ofa class are by default public.
2.Data members of a class are by default private.
3.Member functions ofa class are by default public.
4.A private function of a class can access a public function within the same class.
5.Member function of a class are by default private.
  1, 3, 5
  1, 4
  1, 4, 5
  1, 2, 3
28. 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.
  1, 3
  2, 4
  4, 5
  3, 5
29. 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);
  20
  4
  18
  10
30. Which of the following statements is correct about constructors in C#.NET?
  A constructor cannot be declared as private.
  A constructor cannot be overloaded.
  A constructor can be a static constructor.
  A constructor cannot access static data.
©2024 WithoutBook