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 40 C

Top 40 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].
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.
31. Which of the following statements is correct?
  Procedural Programming paradigm is different than structured programming paradigm.
  Object Oriented Programming paradigm stresses on dividing the logic into smaller parts and writing procedures for each part.
  Classes and objects are corner stones of structured programming paradigm.
  Object Oriented Programming paradigm gives equal importance to data and the procedures that work on the data.
32. Which of the following statements are correct about the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
class Sample
{
int i, j;
public void SetData(int ii, int jj)
{
this.i = ii;
this.j = jj
}
}
class MyProgram
{
static void Main(string[ ] args)
{
Sample s1 = new Sample();
s1.SetData(10, 2);
Sample s2 = new Sample();
s2.SetData(5, 10);
}
}
}
  The code will not compile since we cannot explicitly use this.
  Using this in this program is necessary to properly set the values in the object.
  The call to SetData() is wrong since we have not explicitly passed the thisreference to it.
  Contents of this will be different during each call to SetData().
33. Which of the following statements is correct about classes and objects in C#.NET?
  Class is a value type.
  Since objects are typically big in size, they are created on the stack.
  Objects of smaller size are created on the heap.
  Objects are always nameless.
34. Which one of the following statements is correct?
  Array elements can be of integer type only.
  The rank of an Array is the total number of elements it can contain.
  The length of an Array is the number of dimensions in the Array.
  The default value of numeric array elements is zero.
35. If a is an array of 5 integers then which of the following is the correct way to increase its size to 10 elements?20.If a is an array of 5 integers then which of the following is the correct way to increase its size to 10 elements?
  int[] a = new int[5];
int[] a = new int[10];
  int[] a = int[5];
int[] a = int[10];
  int[] a = new int[5];
a.Length = 10 ;
  int[] a = new int[5];
a = new int[10];
36. How will you complete the foreach loop in the C#.NET code snippet given below such that it correctly prints all elements of the array a?

int[][]a = new int[2][];
a[0] = new int[4]{6, 1 ,4, 3};
a[1] = new int[3]{9, 2, 7};
foreach (int[ ] i in a)
{
/* Add loop here */
Console.Write(j + " ");
Console.WriteLine();
}
  foreach (int j = 1; j < a(0).GetUpperBound; j++)
  foreach (int j = 1; j < a.GetUpperBound (0); j++)
  foreach (int j in a.Length)
  foreach (int j in i)
37. Which of the following statements are correct about arrays used in C#.NET?

1.Arrays can be rectangular or jagged.
2.Rectangular arrays have similar rows stored in adjacent memory locations.
3.Jagged arrays do not have an access to the methods of System.ArrayClass.
4.Rectangular arrays do not have an access to the methods of System.ArrayClass.
5.Jagged arrays have dissimilar rows stored in non-adjacent memory locations.
  1, 2
  1, 3, 5
  3, 4
  1, 2, 5
38. How many enumerators will exist if four threads are simultaneously working on an ArrayList object?
  1
  3
  2
  4
39. In which of the following collections is the Input/Output based on a key?
1.Map
2.Stack
3.BitArray
4.HashTable
5.SortedList
  1 and 2 only
  2 and 3 only
  1, 2 and 3 only
  4 and 5 only
40. Which of the following is NOT an interface declared in System.Collectionsnamespace?
  IComparer
  Enumerable
  Enumerator
  IDictionaryComparer
©2017 WithoutBook