C++ Programming Multiple Choice Question - Namespaces
This section focuses on the "Namespace" in C++ programming langauge. These Multiple Choice Questions (MCQ) should be practiced to improve the C++ programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1. Which operator is used to signify the namespace in c++?
View Answer
2. Identify the incorrect statement?
View Answer
3. What is the use of Namespace?
View Answer
4. What is the general syntax for accessing the namespace variable?
View Answer
5. The use of Namespace is to structure a program into logical units?
View Answer
6. Which of the following is correct option?
#include<iostream>
using namespace std;
namespace lfc1
{
int var = 30;
}
namespace lfc2
{
double var = 13.5478;
}
int main ()
{
int a;
a = lfc1::var + lfc2::var;
cout << a;
return 0;
}
View Answer
7. Which of the following is correct option?
#include<iostream>
using namespace std;
namespace lfc1
{
double var =30.1234;
}
namespace lfc2
{
double var = 13.5478;
}
int main ()
{
double a;
a = lfc1::var - lfc2::var;
cout << a;
return 0;
}
View Answer
8. Which of the following is correct option?
#include<iostream>
using namespace std;
namespace lfc1
{
int x = 10;
}
namespace lfc2
{
int x = 20;
}
int main ()
{
int x = 30;
lfc1::x;
lfc2::x;
cout << x;
return 0;
}
View Answer
9. Which of the following is correct option?
#include<iostream>
using namespace std;
namespace lfc
{
int x = 10;
}
namespace lfc
{
int x = 20;
}
int main ()
{
int x = 30;
lfc::x;
lfc::x;
cout << x;
return 0;
}
View Answer
10. Which keyword is used to access the variable in the namespace?
View Answer
Also check :
Discussion