Without Book Interview Questions and Answers | Online Test | Moct Test
Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store
Institute Training Search by Name or Email

Exams Attended

Make Homepage

Bookmark this page

Subscribe Email Address

Top 20 C

Top 20 C
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].
©2017 WithoutBook