Namespaces Questions and Answers
Practice ModeShowing 10 of 30 questions
Q21
What does the "using" directive do?
Answer: Option B
Explanation: The using directive imports types from other namespaces, allowing you to use them without full qualification.
Q22
Which statement about namespace accessibility is correct?
Answer: Option B
Explanation: Namespaces themselves don't have access modifiers; they are always publicly accessible.
Q23
How do you reference a class from the global namespace?
Answer: Option B
Explanation: The global:: prefix is used to explicitly reference types from the global namespace.
Q24
What is the relationship between namespaces and assemblies?
Answer: Option C
Explanation: A single assembly can contain multiple namespaces, and a single namespace can span multiple assemblies.
Q25
Which of these correctly demonstrates namespace usage?
Answer: Option D
Explanation: Proper namespace usage involves declaring namespaces and using directives to access types.
Q26
What is the effect of the "using" directive within a namespace declaration?
Answer: Option B
Explanation: Using directives can be placed inside namespace declarations to limit their scope to that namespace.
Q27
How can you prevent namespace pollution?
Answer: Option B
Explanation: Using specific using directives instead of wildcards and organizing code in appropriate namespaces prevents pollution.
Q28
What is namespace collision?
Answer: Option B
Explanation: Namespace collision occurs when the same type name exists in multiple imported namespaces.
Q29
Which directive helps resolve namespace conflicts?
Answer: Option C
Explanation: Namespace aliases using the using directive help resolve conflicts between same-named types.
Q30
What is the default namespace for a new C# console application?
Answer: Option C
Explanation: The default namespace is typically based on the project name in Visual Studio.