Namespaces Questions and Answers
Practice ModeShowing 10 of 30 questions
Q11
What is the primary purpose of namespaces in C#?
Answer: Option B
Explanation: Namespaces help organize code and prevent naming conflicts.
Q12
Which keyword is used to declare a namespace in C#?
Answer: Option B
Explanation: The namespace keyword is used to define a namespace in C#.
Q13
How do you use a class from another namespace without fully qualifying it?
Answer: Option C
Explanation: The using directive allows you to use types from other namespaces without full qualification.
Q14
What happens if two namespaces contain classes with the same name?
Answer: Option B
Explanation: You can use aliases or fully qualified names to resolve ambiguity between same-named classes in different namespaces.
Q15
Which of the following is the correct way to define a namespace?
Answer: Option B
Explanation: Namespace declaration uses the namespace keyword followed by the namespace name and braces.
Q16
What is the global namespace in C#?
Answer: Option B
Explanation: The global namespace is the root namespace that contains all other namespaces and types.
Q17
How can you create a namespace alias in C#?
Answer: Option B
Explanation: Namespace aliases are created using the using directive with an alias assignment.
Q18
Which of these is a valid namespace naming convention?
Answer: Option A
Explanation: Namespaces typically use PascalCase and may contain multiple segments separated by dots.
Q19
What is the purpose of the "using static" directive?
Answer: Option B
Explanation: The using static directive imports static members of a class, allowing you to use them without class qualification.
Q20
How are nested namespaces typically declared?
Answer: Option C
Explanation: Nested namespaces can be declared using dot notation in a single namespace declaration.