Interfaces
- Which keyword is used to access the variable in the namespace?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
using
- What is the output of this program?
#include
using namespace std;
namespace calculation
{
int p;
}
void p()
{
using namespace calculation;
int p;
p = 15;
cout << p;
}
int main()
{
enum letter { K, L};
class K { letter L; };
::p();
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
A scope resolution operator without a scope qualifier refers to the global namespace.
- What is the output of this program?
#include
using namespace std;
namespace calc
{
int p = 12;
}
namespace calc
{
int q = 23;
}
int main(int argc, char * argv[])
{
calc::p = calc::q =6;
cout << calc::p << calc::q;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
We are overriding the value at the main function and so we are getting the output as 66.
- What is the output of this program?
#include
using namespace std;
namespace first
{
int num = 5;
}
namespace second
{
int num = 11;
}
int main ()
{
int num = 27;
first::num;
second::num;
cout << num;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
In this program, as there is lot of variable a and it is printing the value inside the block because it got the highest priority.
- What is the output of this program?
#include
using namespace std;
namespace One
{
int K = 15;
int L = 11;
}
namespace Two
{
double K = 4.016;
double L = 7.6001;
}
int main ()
{
using One::K;
using Two::L;
bool p, q;
p = K > L;
q = One::K < Two::L;
cout << p <<" " << q;
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
We are inter mixing the variable and comparing it which is bigger and smaller and according to that we are printing the output.