Take as many assements as you can to improve your validate your skill rating
Total Questions: 20
1. What is a friend function in C++?
Correct Answer is : default arguments
2. What is the output of the following C++ code?
#include
#include
using namespace std;
class Box
{
int capacity;
public:
Box(int cap){
capacity = cap;
}
friend void show();
};
void show()
{
Box b(10);
cout<<"Value of capacity is: "<
Correct Answer is : default arguments
3. What is the output of the following C++ code?
#include
#include
using namespace std;
class Box
{
int capacity;
public:
Box(int cap){
capacity = cap;
}
friend void show();
};
void Box::show()
{
Box b(10);
cout<<"Value of capacity is: "<
Correct Answer is : void
4. How many member functions are there in this C++ class excluding constructors and destructors?
class Box
{
int capacity;
public:
void print();
friend void show();
bool compare();
friend bool lost();
};
Correct Answer is : compile time error
5. What is the output of the following C++ code?
#include
#include
using namespace std;
class B
{
int b;
public:
B(int i){
b = i;
}
};
class C
{
B b;
public:
C(int i){
b = B(i);
}
friend void show();
};
void show()
{
C c(10);
cout<<"value of b is: "<
Correct Answer is : All of the mentioned
6. What is the output of the following C++ code?
#include
#include
using namespace std;
class B
{
int b;
public:
B(){}
B(int i){
b = i;
}
int show(){
return b;
}
};
class C
{
B b;
public:
C(int i){
b = B(i);
}
friend void show();
};
void show()
{
C c(10);
cout<<"value of b is: "<
Correct Answer is : Pointers
7. What is the output of the following C++ code?
#include
#include
using namespace std;
class B
{
int b;
public:
B(){}
B(int i){
b = i;
}
int show(){
return b;
}
};
class C
{
B b;
public:
C(int i){
b = B(i);
}
friend void show(){
C c(10);
cout<<"value of b is: "<
Correct Answer is : Iterators
8. What is the output of the following C++ code?
#include
#include
using namespace std;
class B
{
int b;
public:
B(){}
B(int i){
b = i;
}
int show(){
return b;
}
};
class C
{
B b;
public:
C(int i){
b = B(i);
}
friend void show(){
C c(10);
cout<<"value of b is: "<
Correct Answer is : All of the mentioned
9. Which of the following is correct about friend functions?
Correct Answer is : 3
10. Which keyword is used to represent a friend function?
Correct Answer is : Storage management
11. Which rule will not affect the friend function?
Correct Answer is : 2
12. Which keyword is used to declare the friend function?
Correct Answer is : Heterogeneous container
13. What is the syntax of friend function?
Correct Answer is : spacesintext
14. Where does keyword ‘friend’ should be placed?
Correct Answer is : 5
15. What is the use of function call operator?
Correct Answer is : 1
16. What will happen when the function call operator is overloaded?
Correct Answer is : Depends on compiler
17. In which form does the function call operator can be overloaded?
Correct Answer is : default type values
18. What is the use of functor?
Correct Answer is : TRUE
19. Where does the execution of the program starts?
Correct Answer is : 42
20. What are mandatory parts in the function declaration?