Explore topic-wise MCQs in C Sharp Programming.

This section includes 31 Mcqs, each offering curated multiple-choice questions to sharpen your C Sharp Programming knowledge and support exam preparation. Choose a topic below to get started.

1.

For constructor overloading, each constructor must differ in ___________ and __________

A. Number of arguments and type of arguments
B. Number of arguments and return type
C. Return type and type of arguments
D. Return type and definition
Answer» B. Number of arguments and return type
2.

Which among the following is correct for the class defined below?

A. Object s3, syntax error
B. Only object s1 and s2 will be created
C. Program runs and all objects are created
D. Program will give compile time errorView Answer
Answer» D. Program will give compile time errorView Answer
3.

Which among the following helps to create a temporary instance?

A. Implicit call to a default constructor
B. Explicit call to a copy constructor
C. Implicit call to a parameterized constructor
D. Explicit call to a constructor
Answer» E.
4.

Which object will be created first?

A. s1 then s2 then s3
B. s3 then s2 then s1
C. s2 then s3 then s1
D. all are created at same timeView Answer
Answer» B. s3 then s2 then s1
5.

If the object is passed by value to a copy constructor?

A. Only public members will be accessible to be copied
B. That will work normally
C. Compiler will give out of memory error
D. Data stored in data members won’t be accessible
Answer» D. Data stored in data members won’t be accessible
6.

Which among the following is true for copy constructor?

A. The argument object is passed by reference
B. It can be defined with zero arguments
C. Used when an object is passed by value to a function
D. Used when a function returns an object
Answer» C. Used when an object is passed by value to a function
7.

In multiple inheritance, if class C inherits two classes A and B as follows, which class constructor will be called first?

A. A()
B. B()
C. C()
D. Can’t be determinedView Answer
Answer» B. B()
8.

If class C inherits class B. And B has inherited class A. Then while creating the object of class C, what will be the sequence of constructors getting called?

A. Constructor of C then B, finally of A
B. Constructor of A then C, finally of B
C. Constructor of C then A, finally B
D. Constructor of A then B, finally C
Answer» E.
9.

Default constructor must be defined, if parameterized constructor is defined and the object is to be created without arguments.

A. True
B. False
Answer» B. False
10.

If a programmer defines a class and defines a default value parameterized constructor inside it.He has not defined any default constructor. And then he try to create the object without passing arguments, which among the following will be correct?

A. It will not create the object (as parameterized constructor is used)
B. It will create the object (as the default arguments are passed)
C. It will not create the object (as the default constructor is not defined)d) It will create the object (as at least some constructor is define
D. It will create the object (as the default arguments are passed)c) It will not create the object (as the default constructor is not defined)d) It will create the object (as at least some constructor is defined)
Answer» C. It will not create the object (as the default constructor is not defined)d) It will create the object (as at least some constructor is define
11.

How many types of constructors are available for use in general (with respect to parameters)?

A. 2
B. 3
C. 4
D. 5
Answer» B. 3
12.

In which access should a constructor be defined, so that object of the class can be created in any function?

A. Public
B. Protected
C. Private
D. Any access specifier will work
Answer» B. Protected
13.

Which among the following is not a necessary condition for constructors?

A. Its name must be same as that of class
B. It must not have any return type
C. It must contain a definition body
D. It can contains arguments
Answer» D. It can contains arguments
14.

Which among the following is called first, automatically, whenever an object is created?

A. Class
B. Constructor
C. New
D. Trigger
Answer» C. New
15.

Which of the following statements are correct about static functions?

A. Static functions are invoked using objects of a class.
B. Static functions can access static data as well as instance data.
C. Static functions are outside the class scope.
D. Static functions are invoked using class.
Answer» E.
16.

In which of the following should the methods of a class differ if they are to be treated as overloaded methods? Type of arguments Return type of methods Number of arguments Names of methods Order of arguments

A. 2, 4
B. 3, 5
C. 1, 3, 5
D. 3, 4, 5
Answer» D. 3, 4, 5
17.

Which of the following statements are correct about static functions?

A. Static functions are invoked using objects of a class.
B. Static functions can access static data as well as instance data.
C. Static functions are outside the class scope.
D. Static functions are invoked using class.
Answer» E.
18.

Is it possible for you to prevent an object from being created by using zero argument constructor?

A. Yes
B. No
Answer» B. No
19.

Which of the following statements are correct about constructors in C#.NET? Constructors cannot be overloaded. Constructors always have the name same as the name of the class. Constructors are never called explicitly. Constructors never return any value. Constructors allocate space for the object in memory.

A. 1, 3, 5
B. 2, 3, 4
C. 3, 5
D. 4, 5
Answer» C. 3, 5
20.

Which of the following statements is correct about constructors in C#.NET?

A. A constructor cannot be declared as private.
B. A constructor cannot be overloaded.
C. A constructor can be a static constructor.
D. A constructor cannot access static data.
Answer» D. A constructor cannot access static data.
21.

What will be the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class Sample { public static void fun1() { Console.WriteLine("Bix1 method"); } public void fun2() { fun1(); Console.WriteLine("Bix2 method"); } public void fun2(int i) { Console.WriteLine(i); fun2(); } } class MyProgram { static void Main(string[ ] args) { Sample s = new Sample(); Sample.fun1(); s.fun2(123); } } }

A. Bix1 method 123 Bixl method Bix2 method
B. Bix1 method 123 Bix2 method
C. Bix2 method 123 Bix2 method Bixl method
D. Bixl method 123
Answer» B. Bix1 method 123 Bix2 method
22.

How many times can a constructor be called during lifetime of the object?

A. As many times as we call it.
B. Only once.
C. Depends upon a Project Setting made in Visual Studio.NET.
D. Any number of times before the object gets garbage collected.
Answer» C. Depends upon a Project Setting made in Visual Studio.NET.
23.

Can static procedures access instance data?

A. Yes
B. No
Answer» C.
24.

Which of the following statements are correct about the C#.NET code snippet given below? class Sample { static int i; int j; public void proc1() { i = 11; j = 22; } public static void proc2() { i = 1; j = 2; } static Sample() { i = 0; j = 0; } }

A. i cannot be initialized in proc1().
B. proc1() can initialize i as well as j.
C. j can be initialized in proc2().
D. The constructor can never be declared as static.
Answer» C. j can be initialized in proc2().
25.

What will be the output of the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class Sample { static Sample() { Console.Write("Sample class "); } public static void Bix1() { Console.Write("Bix1 method "); } } class MyProgram { static void Main(string[ ] args) { Sample.Bix1(); } } }

A. Sample class Bix1 method
B. Bix1 method
C. Sample class
D. Bix1 method Sample class
Answer» B. Bix1 method
26.

Which of the following statements is correct about the C#.NET code snippet given below? namespace IndiabixConsoleApplication { class Sample { public int func() { return 1; } public Single func() { return 2.4f ; } } class Program { static void Main(string[ ] args) { Sample s1 = new Sample(); int i; i = s1.func(); Single j; j = s1.func(); } } }

A. func() is a valid overloaded function.
B. Overloading works only in case of subroutines and not in case of functions.
C. func() cannot be considered overloaded because: return value cannot be used to distinguish between two overloaded functions.
D. The call to i = s1.func() will assign 1 to i.
Answer» D. The call to i = s1.func() will assign 1 to i.
27.

Is it possible to invoke Garbage Collector explicitly?

A. Yes
B. No
C. i cannot be initialized in proc1().
D. proc1() can initialize i as well as j.
Answer» B. No
28.

Which of the following statements is correct about constructors?

A. If we provide a one-argument constructor then the compiler still provides a zero-argument constructor.
B. Static constructors can use optional arguments.
C. Overloaded constructors cannot use optional arguments.
D. If we do not provide a constructor, then the compiler provides a zero-argument constructor.
Answer» E.
29.

Which of the following is the correct way to define the constructor(s) of the Sample class if we are to create objects as per the C#.NET code snippet given below? Sample s1 = new Sample(); Sample s2 = new Sample(9, 5.6f);

A. public Sample() { i = 0; j = 0.0f; } public Sample (int ii, Single jj) { i = ii; j = jj; }
B. public Sample (Optional int ii = 0, Optional Single jj = 0.0f) { i = ii; j = jj; }
C. public Sample (int ii, Single jj) { i = ii; j = jj; }
D. Sample s;
Answer» B. public Sample (Optional int ii = 0, Optional Single jj = 0.0f) { i = ii; j = jj; }
30.

Which of the following statements are correct about static functions? Static functions can access only static data. Static functions cannot call instance functions. It is necessary to initialize static data. Instance functions can call static functions and access static data. this reference is passed to static functions.

A. 1, 2, 4
B. 2, 3, 5
C. 3, 4
D. 4, 5
Answer» B. 2, 3, 5
31.

Which of the following ways to create an object of the Sample class given below will work correctly? class Sample { int i; Single j; double k; public Sample (int ii, Single jj, double kk) { i = ii; j = jj; k = kk; } }

A. Sample s1 = new Sample();
B. Sample s1 = new Sample(10);
C. Sample s2 = new Sample(10, 1.2f);
D. Sample s3 = new Sample(10, 1.2f, 2.4);
Answer» E.