6.
What will be the output of the following C++ code?
#include <iostream>
class Test
{
public:
void fun();
};
static void Test::fun()
{
std::cout<<“fun() is static”;
}
int main()
{
Test::fun();
return 0;
}
a) fun() is static
b) Compile-time Error
c) Run-time Error
d) Nothing is printed
7.
Const qualifier can be applied to which of the following?
i) Functions inside a class
ii) Arguments of a function
iii) Static data members
iv) Reference variables
a) i, ii and iii
b) i, ii, iii, and iv
c) ii, iii and iv
d) i only
8.
What will be the output of the following C++ code?
#include <iostream> using namespace std; class Point { int x, y; public: Point(int i = 0, int j =0) { x = i; y = j; } int getX() const { return x; } int getY() {return y;} }; int main() { const Point t; cout << t.getX() << " "; cout << t.getY(); return 0; }
a) 0 0
b) Garbage values
c) Compile erroe
d) Segmentation fault
9.
What will be the output of the following C++ code?
#include <iostream> using namespace std; int main() { const int x; x = 10; cout<<x; return 0; }
a) 10
b) Garbage value
c) Error
d) Segmentation fault
10.
What will be the output of the following C++ code?
#include <iostream> int const s=9; int main() { std::cout << s; return 0; }
a) 9
b) Garbage value
c) Error
d) Segmentation fault