C# Multiple Choice Questions – Namespaces

This section of our 1000+ C# MCQs focuses on namespaces in C# Programming Language.

1. Which of the following is not a namespace in the .NET Framework Class Library?
a) System.Process
b) System.Security
c) System.Threading
d) System.xml
View Answer

Answer: a
Explanation: None.

2. Which is the correct statement about the namespaces in C#.NET?
a) Nesting of namespaces is permitted, provided all the inner namespaces are declared in the same file
b) A namespace cannot be tested
c) There is no limit on the number of levels while nesting namespaces
d) All of the mentioned
View Answer

Answer: c
Explanation: None.

3. Which among the following does not belong to the C#.NET namespace?
a) class
b) struct
c) enum
d) data
View Answer

Answer: d
Explanation: None.
advertisement
advertisement

4. Which among the following is a correct statement about namespace used in C#.NET?
a) Classes must belong to a namespace, whereas structures need not
b) All elements of the namespace must to belong to one file
c) If not mentioned, a namespace takes the name of the current project
d) All of the mentioned
View Answer

Answer: c
Explanation: None.

5. Which among the given is not a correct way to call the method Issue() defined in the following C# code snippet?

  1. class Book
  2. {
  3.     public void issue()
  4.     {
  5.       /* code */
  6.     }
  7. }
  8. class Journel
  9. {
  10.      public void issue()
  11.      {
  12.          /* code */
  13.      }
  14. }

a)

College.Lib.Book b = new College.Lib.Book();
b.issue();
advertisement

b)

Book b = new Book();
b.issue();

c)

using College.Lib;
Book b = new Book();
b.issue();
advertisement

d) All of the mentioned
View Answer

Answer: b
Explanation: None.

6. Which among the following statements are not correct about a namespace used in C#.NET?
a) Nested namespaces are allowed
b) Importing outer namespaces imports inner namespace
c) Nested namespaces are allowed
d) Importing outer namespace does not import inner namespace
View Answer

Answer: b
Explanation: None.

7. Which among the following is a .NET namespace?
a) System.Web
b) System.Process
c) System.Drawing2D
d) System.Drawing3D
View Answer

Answer: a
Explanation: None.

8. If a class named csharp is present in namespace n1 as well as in namespace n2, then which of the following is the correct way to use csharp class?
a)

   class Program
   {
     static void Main(string[] args)
     {
        import n1;
        csharp x = new csharp();
        x.fun();
        import n2;
        csharp y = new csharp();
        y.fun();
     }
   }

b)

   import n1;
   import n2;
   namespace ConsoleApplication1
   {
      class Program
   {
     static void Main(string[] args)
     {
 
       n1.csharp x = new n1.csharp();
        x.fun();
        import n2;
        n2.csharp y = new n2.csharp();
        y.fun();
     }
   }
}

c)

   class Program
   {
     static void Main(string[] args)
     {
       using n1;
       csharp x = new csharp();
       x.fun();
       using n2;
       csharp y = new csharp();
        y.fun();
     }
   }

d)

   using n1;
   using n2;
   namespace ConsoleApplication1
   {
      class Program
   {
     static void Main(string[] args)
     {
 
       n1.csharp x = new n1.csharp();
        x.fun();
        import n2;
        n2.csharp y = new n2.csharp();
        y.fun();
     }
   }
}
View Answer
Answer: c
Explanation: None.
 
 

9. If ListBox is the class of System.Windows.Forms namespace. Then, the correct way to create an object of ListBox class is?
a)

using System.Windows.Forms;
ListBox I = new ListBox();

b) System.Windows.Forms.ListBox I = new System.Windows.Forms.ListBox();
c) using LBControl I = new System.Windows.Forms.ListBox;
d) All of the mentioned
View Answer

Answer: d
Explanation: None.

10. Which among the following is the correct statement about the using statement used in C#.NET?
a) A C#.NET source code file consists of any number of using statement
b) By using ‘using’ statement it’s possible to create an alias for the namespace but not for the namespace element
c) It is permitted to define a member at namespace level using alias
d) Using statement can be placed anywhere in the C#.NET source code file
View Answer

Answer: c
Explanation: None.

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

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

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.