Take as many assements as you can to improve your validate your skill rating
Total Questions: 20
1. How many types of loops are there in C++?
Correct Answer is : *
2. Which looping process is best used when the number of iterations is known?
Correct Answer is : x is a pointer to a string, y is a string
3. What is the output of the following C++ code?
#include
using namespace std;
class Test
{
static int x;
public:
Test() { x++; }
static int getX() {return x;}
};
int Test::x = 0;
int main()
{
cout << Test::getX() << " ";
Test t[5];
cout << Test::getX();
}
Correct Answer is : point to a tye
4. What is the output of the following C++ code?
#include
using namespace std;
class Player
{
private:
int id;
static int next_id;
public:
int getID() { return id; }
Player() { id = next_id++; }
};
int Player::next_id = 1;
int main()
{
Player p1;
Player p2;
Player p3;
cout << p1.getID() << " ";
cout << p2.getID() << " ";
cout << p3.getID();
return 0;
}
Correct Answer is : int i; double* dp = &i;
5. Which of the following is correct about static variables?
Correct Answer is : p now points to b
6. What is the output of the following C++ code?
#include
using namespace std;
class A
{
private:
int x;
public:
A(int _x) { x = _x; }
int get() { return x; }
};
class B
{
static A a;
public:
static int get()
{ return a.get(); }
};
int main(void)
{
B b;
cout << b.get();
return 0;
}
Correct Answer is : it will return some random number
7. What is the output of the following C++ code?
#include
using namespace std;
class Test
{
private:
static int count;
public:
Test& fun();
};
int Test::count = 0;
Test& Test::fun()
{
Test::count++;
cout << Test::count << " ";
return *this;
}
int main()
{
Test t;
t.fun().fun().fun().fun();
return 0;
}
Correct Answer is : int **fun(float*, char**)
8. What is the output of the following C++ code?
#include
class Test
{
public:
void fun();
};
static void Test::fun()
{
std::cout<<"fun() is static";
}
int main()
{
Test::fun();
return 0;
}
Correct Answer is : ABCDEFGHIJ
9. 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
Correct Answer is : fg
10. What is the output of the following C++ code?
#include
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;
}
Correct Answer is : p is array of pointer to function
11. What is the output of the following C++ code?
#include
int main()
{
const int x;
x = 10;
printf("%d", x);
return 0;
}
Correct Answer is : 4
12. What is the output of the following C++ code?
#include
int const s=9;
int main()
{
std::cout << s;
return 0;
}
Correct Answer is : 21 21 21
13. What is a pair?
Correct Answer is : ava
14. Which header file is required to use pair container in your program?
Correct Answer is : 5
15. Which of the following is the correct syntax of using pair p?
Correct Answer is : address of arr
16. Which of the following operations can be performed on a pair?
Correct Answer is : 10,20,30,40,50,
17. Which operator is used to access the first or second element of a pair?
Correct Answer is : 13
18. Which of the following is the correct syntax of accessing the first element of a pair p?
Correct Answer is : Non-static members of class objects
19. Which of the following is the correct syntax of accessing the second element of a pair p?
Correct Answer is : Normal pointer
20. What is the output of the following C++ program?
#include
#include
using namespace std;
int main ()
{
pair p(1,2);
cout<<"Pair(first,second) = ("<