CPP Namespace MCQ
Cpp MCQ(1) Which of the following parenthesis are used to define scope of namespace while using namespace directive?
A) Square
B) Curly
C) Small
D) Angle
Explanation
Curly parenthesis are used when we want to use multiple namespace directive in single program.
(2) An alternative or short nane of existing namespace is called.
A) alias
B) duplicate
C) namespace2
D) other_namespace
Explanation
We can also assign any other alternative or short name to already defined namespace. This is called alias.
(3) How many methods to access namespace elements?
A) 1
B) 2
C) 5
D) Multiple
Explanation
There are two methods, first Using namespace directive and second is using scope resolution operator.
(4) Which of the following is standard namespace identifier?
A) standard
B) common
C) cin
D) std
Explanation
std is the identifier of standard namespace.
(5) Which directive is used for namespace in C++?
A) accessing namespace
B) including namespace
C) using namespace
D) with namespace
Explanation
using namespace directive is used to access all elements of particular namespace without using scope resolution operator.
(6) Which of the following can be defined in namespace?
A) Variables
B) Labels
C) Functions
D) All C++ valid statements
Explanation
Every C++ valid statement can be part of namespace.
(7) Which of following operator is used to access c++ namespace elements?
A) . (dot)
B) :: (scope resolution)
C) & (ampersand)
D) # (hash)
Explanation
Scope resolution operator with namespace identifier is used to access its elements.