logo
  • Home
  • About
  • Training
  • Programming
  • CS
  • IT
  • IS
  • ECE
  • EEE
  • EE
  • Civil
  • Mechanical
  • Chemical
  • Metallurgy
  • Instrumentation
  • Aeronautical
  • Aerospace
  • Biotechnology
  • Agriculture
  • MCA
  • BCA
  • Internship
  • Contact

C# Multiple Choice Questions | MCQs | Quiz

C# Interview Questions and Answers
Pratice C# questions and answers for interviews, campus placements, online tests, aptitude tests, quizzes and competitive exams.

Get Started

•   Integer Data Types
•   Floating Data Types
•   String Literals
•   Variables Initialization
•   Variables Scope & Lifetime
•   Expression Type Conversion
•   Arithmetic Operators
•   Logical Operators
•   Bit Wise Operators
•   IF Statements
•   Switch Statements
•   For Loop Statements
•   While Loop Statements
•   Do While Loop Statements
•   Continue & Goto statement
•   Class Fundamentals
•   Reference Variables
•   Methods in Class
•   Constructors in Class
•   Destructors in Class
•   Array & Initialization
•   Strings Basic Operation
•   String Class Description
•   Strings Comparison
•   Modifying Strings
•   Characters Operation
•   Private Access Modifier
•   Ref & Out Parameters
•   Variable Arguements
•   Polymorphism
•   Structures
•   Enumerations
•   Inheritance Fundamentals
•   Inheritance Implementation
•   Method Overloading
•   Method Overriding
•   Constructor Overloading
•   Abstract Class & Methods
•   Interfaces Introduction
•   Interfaces Implementation
•   Overloaded Operators
•   Recursion
•   Indexers Basics
•   Properties Basics
•   Properties & Its Application
•   Exception Handling Basics
•   Exception Implementation
•   Built In Exceptions
•   Detail Try & Catch
•   Attributes
•   Console I/O Operations
•   Reading Console Input
•   Writing Console Output
•   Stream Classes Basics
•   Byte Stream
•   Character Stream
•   Delegates Fundamentals
•   Detail Delegates
•   Generics Fundamentals
•   Generic Methods
•   LINQ Fundamentals
•   LINQ Operation & Query
•   Array Class Basics
•   Runtime Type
•   Reflections Basics
•   Collection Classes
•   Maths Class
•   C# Rounding Functions
•   Multi-threaded Programs - 1
•   Multi-threaded Programs - 2
•   Iterators
•   Namespaces Fundamentals
•   Preprocessor Fundamentals
•   Parameters Method
•   Networking Fundamentals
•   URI Class
•   Network Errors Handling
•   Type Interface
•   Unsafe Code & Pointers
•   Pointers Operation - 1
•   Pointers Operation - 2
•   Class Accessor Controls
•   String Formatting Basics
•   String Formatting - 1
•   String Formatting - 2

Best Reference Books

C# Books
« Prev Page
Next Page »

C# Questions & Answers – Constructor Overloading

Posted on September 11, 2013 by staff10

This section of our 1000+ C# multiple choice questions focuses on constructor overloading in C# Programming Language.

1. What will be the output of the given set of code?

  1.  class maths
  2.  {
  3.      public int length;
  4.      public int breadth;
  5.      public maths(int x, int y)
  6.      {
  7.          length = x;
  8.          breadth = y;
  9.          Console.WriteLine(x + y);
  10.      }
  11.      public maths(double x, int y)
  12.      {
  13.          length = (int)x;
  14.          breadth = y;
  15.          Console.WriteLine(x * y);
  16.      }
  17.  }
  18. class Program
  19. {
  20.     static void Main(string[] args)
  21.     {
  22.         maths m = new maths(20, 40);
  23.         maths k = new maths(12.0, 12);
  24.         Console.ReadLine();
  25.     }
  26. }

a) 60, 24
b) 60, 0
c) 60, 144
d) 60, 144.0
View Answer

Answer: c
Explanation: Matching the values passed as parameters.The respective constructors are overloaded according to the matching parameter type.
Output : 60
144

2. What will be the output of the given set of code?

  1.  class maths
  2.  {
  3.      public int length;
  4.      public int breadth;
  5.      public  maths(int x)
  6.      {
  7.          length = x + 1;
  8.      }
  9.      public maths(int x, int y)
  10.      {
  11.          length = x + 2;
  12.      }
  13.  }
  14.  class Program
  15.  {
  16.      static void Main(string[] args)
  17.      {
  18.          maths m = new maths(6);
  19.          maths k = new maths(6, 2);
  20.          Console.WriteLine(m.length);
  21.          Console.WriteLine(k.length);
  22.          Console.ReadLine();
  23.      }
  24.  }

a) 8, 8
b) 0, 2
c) 8, 10
d) 7, 8
View Answer

Answer: d
Explanation: None.

3. What will be the output of the given set of code?

  1.  class maths
  2.  {
  3.      public maths()
  4.      {
  5.          Console.WriteLine("constructor 1 :");
  6.      }
  7.      public maths(int x)
  8.      {
  9.          int p = 2;
  10.          int u;
  11.          u = p + x;
  12.          Console.WriteLine("constructor 2: " +u);
  13.      }
  14.  }
  15.  class Program
  16.  {
  17.      static void Main(string[] args)
  18.      {
  19.          maths k = new maths(4);
  20.          maths t = new maths();
  21.          Console.ReadLine();
  22.      }
  23.  }

a) constructor 1:
constructor 2: 6
b) constructor 2: 6
constructor 2: 6
c) constructor 2: 6
constructor 1:
d) none of the mentioned
View Answer

Answer: c
Explanation: None.
Output: constructor 2: 6
constructor 1:

4. What will be the output of the given set of code?

  1. class maths
  2. {
  3.     int i;
  4.     public maths(int x)
  5.     {
  6.         i = x;
  7.         Console.WriteLine(" hello: ");
  8.     }
  9. }
  10. class maths1 : maths
  11. {
  12.     public  maths1(int x) :base(x)
  13.     {
  14.         Console.WriteLine("bye");
  15.     }
  16. }
  17. class Program
  18. {
  19.     static void Main(string[] args)
  20.     {
  21.         maths1 k = new maths1(12);
  22.         Console.ReadLine();
  23.     }
  24. }

a) hello bye
b) 12 hello
c) bye 12
d) Compile time error
View Answer

Answer: a
Explanation: None.

5. What will be the output of the given set of code?

  1.  class maths
  2.  {
  3.      int i;
  4.      public maths(int ii)
  5.      {
  6.          ii = 12;
  7.          int j = 12;
  8.          int r = ii * j;
  9.          Console.WriteLine(r);
  10.      }
  11.  }
  12.  class maths1 : maths
  13.  {
  14.      public maths1(int u) :base(u)
  15.      {
  16.          u = 13;
  17.          int h = 13;
  18.          Console.WriteLine(u + h);
  19.      }
  20.  }
  21.  class maths2 : maths1
  22.  {
  23.      public maths2(int k) :base(k)
  24.      {
  25.          k = 24;
  26.          int o = 6 ;
  27.          Console.WriteLine(k /o);
  28.      }
  29.  }
  30.  class Program
  31.  {
  32.      static void Main(string[] args)
  33.      {
  34.          maths2 t = new maths2(10);
  35.          Console.ReadLine();
  36.      }
  37.  }

a) 4, 26, 144
b) 26, 4, 144
c) 144, 26, 4
d) 0, 0, 0
View Answer

Answer: c
Explanation: None.

6. Which keyword is used to refer baseclass constructor to subclass constructor?
a) This
b) Static
c) Base
d) Extend
View Answer

Answer: c
Explanation: None.

7. When we call a constructor method among different given constructors. We match the suitable constructor by matching the name of constructor first , then the number and then the type of parameters to decide which constructor is to be overloaded.The process is also known as?
a) Method overriding
b) Inheritance
c) Polymorphism
d) Encapsulation
View Answer

Answer: c
Explanation: None.

8. Correct statement about constructor overloading in C# is?
a) Overloaded constructors have the same name as the class
b) Overloaded constructors cannot use optional arguments
c) Overloaded constructors can have different type of number of arguments as well as differ in number of arguments
d) All of the mentioned
View Answer

Answer: c
Explanation: By definition of overloaded constructors.

9. What will be the output of the given set of code?

  1.   class maths
  2.   {
  3.       static maths()
  4.       {
  5.           int s = 8;
  6.           Console.WriteLine(s);
  7.       }
  8.       public  maths(int f)
  9.       {
  10.           int h = 10;
  11.           Console.WriteLine(h);
  12.       }
  13.   }
  14.   class Program
  15.   {
  16.       static void Main(string[] args)
  17.       {
  18.           maths p = new maths(0);
  19.           Console.ReadLine();
  20.       }
  21.   }

a) 10, 10
b) 0, 10
c) 8, 10
d) 8, 8
View Answer

Answer: c
Explanation: None.
Output: 8, 10

10. What will be the output of the given set of code?

  1. class maths
  2. {
  3.     int i;
  4.     public  maths(int ii)
  5.     {
  6.         ii = -25;
  7.         int g;
  8.         g = ii > 0 ? ii : ii * -1;
  9.         Console.WriteLine(g);
  10.     }
  11. }
  12. class maths1 :maths
  13. {
  14.     public  maths1(int ll) :base(ll)
  15.     {
  16.         ll = -1000;
  17.         Console.WriteLine((ll > 0 ? ll : ll * -1));
  18.     }
  19. }
  20. class Program
  21. {
  22.     static void Main(string[] args)
  23.     {
  24.         maths1 p = new maths1(6);
  25.         Console.ReadLine();
  26.     }
  27. }

a) -25
-1000
b) -1000
-25
c) 25
1000
d) None of the mentioned
View Answer

Answer: c
Explanation: None.
Output : 25, 1000

Sanfoundry Global Education & Learning Series – C# Programming Language.

Here’s the list of Best Reference Books in C# Programming Language.

To practice all features of C# programming language, here is complete set on 1000+ Multiple Choice Questions and Answers on C#.

« Prev Page - C# Questions & Answers – Method Overriding
» Next Page - C# Questions & Answers – Abstract Class & Methods
« C# Questions & Answers – Method Overriding
C# Questions & Answers – Abstract Class & Methods »

Deep Dive @ Sanfoundry:

  1. Java Questions and Answers
  2. C Programming Examples on Strings
  3. C Questions and Answers
  4. C Programming Examples on Set & String Problems & Algorithms
  5. C# Programming Examples on Strings
  6. C# Programming Examples on Functions
  7. Object Oriented Programming Questions and Answers
  8. Java Programming Examples on Classes
  9. C# Questions and Answers
  10. Java Program to Illustrate Use of Chaining Constructor
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer and SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage & Cluster Administration, Advanced C Programming, SAN Storage Technologies, SCSI Internals and Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him below:
LinkedIn | Facebook | Twitter | Google+

Best Careers

Developer Tracks
SAN Developer
Linux Kernel Developer
Linux Driver Developer
Linux Network Developer

Live Training Photos
Mentoring
Software Productivity
GDB Assignment
Sanfoundry is No. 1 choice for Deep Hands-ON Trainings in SAN, Linux & C, Kernel Programming. Our Founder has trained employees of almost all Top Companies in India such as VMware, Citrix, Oracle, Motorola, Ericsson, Aricent, HP, Intuit, Microsoft, Cisco, SAP Labs, Siemens, Symantec, Redhat, Chelsio, Cavium, ST-Micro, Samsung, LG-Soft, Wipro, TCS, HCL, IBM, Accenture, HSBC, Mphasis, Tata-Elxsi, Tata VSNL, Mindtree, Cognizant and Startups.

Best Trainings

SAN I - Technology
SAN II - Admin
Linux Fundamentals
Advanced C Training
Linux-C Debugging
System Programming
Network Programming
Linux Threads
Kernel Programming
Kernel Debugging
Linux Device Drivers

Best Reference Books

Computer Science Books
Algorithm & Programming Books
Electronics Engineering Books
Electrical Engineering Books
Chemical Engineering Books
Civil Engineering Books
Mechanical Engineering Books
Industrial Engineering Books
Instrumentation Engg Books
Metallurgical Engineering Books
All Stream Best Books

Questions and Answers

1000 C Questions & Answers
1000 C++ Questions & Answers
1000 C# Questions & Answers
1000 Java Questions & Answers
1000 Linux Questions & Answers
1000 Python Questions
1000 PHP Questions & Answers
1000 Hadoop Questions
Cloud Computing Questions
Computer Science Questions
All Stream Questions & Answers

India Internships

Computer Science Internships
Instrumentation Internships
Electronics Internships
Electrical Internships
Mechanical Internships
Industrial Internships
Systems Internships
Chemical Internships
Civil Internships
IT Internships
All Stream Internships

About Sanfoundry

About Us
Copyright
TOS & Privacy
Jobs
Bangalore Training
Online Training
SAN Training
Developers Track
Mentoring Sessions
Contact Us
Sitemap
© 2011 Sanfoundry