Exercise: Namespaces

Questions for: Namespaces

Which of the following statements is correct about the using statement used in C#.NET?
A:
using statement can be placed anywhere in the C#.NET source code file.
B:
It is permitted to define a member at namespace level as a using alias.
C:
A C#.NET source code file can contain any number of using statement.
D:
By using using statement it is possible to create an alias for the namespace but not for the namespace element.
Answer: C
No answer description is available. Let's discuss.
Which of the following is correct way to rewrite the C#.NET code snippet given below?
using Microsoft.VisualBasic;
using System.Windows.Forms;
MessageBox.Show("Wait for a" + ControlChars.CrLf + "miracle");
A:
using System.Windows.Forms;
using CtrlChars = Microsoft.VisualBasic.ControlChars; 
MessageBox.Show("Wait for a" + CrLf + "miracle");
B:
using Microsoft.VisualBasic; 
using System.Windows.Forms; 
CtrlChars = ControlChars;
MessageBox.Show("Wait for a" + CtrlChars.CrLf + "miracle");
C:
using Microsoft.VisualBasic; 
using System.Windows.Forms; 
CtrlChars = ControlChars; 
MessageBox.Show ("Wait for a" + CrLf + "miracle");
D:
using System.Windows.Forms;
using CtrlChars = Microsoft.VisualBasic.ControlChars; 
MessageBox.Show("Wait for a" + CtrlChars.CrLf + "miracle");
Answer: D
No answer description is available. Let's discuss.
Which of the following statements is correct about namespaces in C#.NET?
A:
Namespaces can be nested only up to level 5.
B:
A namespace cannot be nested.
C:
There is no limit on the number of levels while nesting namespaces.
D:
If namespaces are nested, then it is necessary to use using statement while using the elements of the inner namespace.
Answer: C
No answer description is available. Let's discuss.
Which of the followings are NOT a .NET namespace?
  1. System.Web
  2. System.Process
  3. System.Data
  4. System.Drawing2D
  5. System.Drawing3D
A:
1, 3
B:
2, 4, 5
C:
3, 5
D:
1, 2, 3
Answer: B
No answer description is available. Let's discuss.
If a class called Point is present in namespace n1 as well as in namespace n2, then which of the following is the correct way to use the Point class?
A:
namespace ExamAdept
{ 
    class MyProgram
    { 
        static void Main(string[] args)
        { 
            import n1; 
            Point x = new Point();
            x.fun();
            import n2;
            Point y = new Point(); 
            y.fun();
        }
    }
}
B:
import n1; 
import n2;
namespace ExamAdept
{ 
    class MyProgram
    { 
        static void Main(string[] args)
        {
            n1.Point x = new n1.Point(); 
            x.fun();
            n2.Point y = new n2.Point(); 
            y.fun();
        }
    }
}
C:
namespace ExamAdept
{ 
    class MyProgram
    {
        static void Main(string[] args)
        {
            using n1;
            Point x = new Point();
            x.fun();
            using n2;
            Point y = new Point();
            y.fun();
        }
    }
}
D:
using n1;
using n2; 
namespace ExamAdept
{ 
    class MyProgram
    { 
        static void Main(string[] args)
        { 
            n1.Point x = new n1.Point(); 
            x.fun();
            n2.Point y = new n2.Point(); 
            y.fun(); 
        } 
    } 
}
Answer: D
No answer description is available. Let's discuss.
Ad Slot (Above Pagination)
Quiz