Online C++ Programming Test - C++ Programming Test 3

Instruction:

  • This is a FREE online test. Beware of scammers who ask for money to attend this test.
  • Total number of questions: 20.
  • Time allotted: 30 minutes.
  • Each question carries 1 mark; there are no negative marks.
  • DO NOT refresh the page.
  • All the best!

Marks : 2/20


Total number of questions
20
Number of answered questions
0
Number of unanswered questions
20
Test Review : View answers and explanation for this test.

1.
Which of the following statement is correct?
Class is an instance of object.
Object is an instance of a class.
Class is an instance of data type.
Object is an instance of data type.
Your Answer: Option
(Not Answered)
Correct Answer: Option

2.
Which of the following is not a type of inheritance?
Multiple
Multilevel
Distributive
Hierarchical
Your Answer: Option
(Not Answered)
Correct Answer: Option

3.
Which of the following keyword is used to overload an operator?
overload
operator
friend
override
Your Answer: Option
(Not Answered)
Correct Answer: Option

4.
Which of the following factors supports the statement that reusability is a desirable feature of a language?
It decreases the testing time.
It lowers the maintenance cost.
It reduces the compilation time.
Both A and B.
Your Answer: Option
(Not Answered)
Correct Answer: Option

5.
What happens if the base and derived class contains definition of a function with same prototype?
Compiler reports an error on compilation.
Only base class function will get called irrespective of object.
Only derived class function will get called irrespective of object.
Base class object will call base class function and derived class object will call derived class function.
Your Answer: Option
(Not Answered)
Correct Answer: Option

6.
Which of the following is a mechanism of static polymorphism?
Operator overloading
Function overloading
Templates
All of the above
Your Answer: Option
(Not Answered)
Correct Answer: Option

7.
Which of the following statement is incorrect?
The default value for an argument can be a global constant.
The default arguments are given in the function prototype.
Compiler uses the prototype information to build a call, not the function definition.
The default arguments are given in the function prototype and should be repeated in the function definition.
Your Answer: Option
(Not Answered)
Correct Answer: Option

8.
Which of the following function / type of function cannot be overloaded?
Member function
Static function
Virtual function
Both B and C
Your Answer: Option
(Not Answered)
Correct Answer: Option

9.
What will be the output of the following program?
#include<iostream.h>
int BixFunction(int a, int b = 3, int c = 3)
{
    cout<< ++a * ++b * --c ; 
    return 0;
}
int main()
{
    BixFunction(5, 0, 0); 
    return 0;
}
8
6
-6
-8
Your Answer: Option
(Not Answered)
Correct Answer: Option

10.
What will be the output of the following program?
#include<iostream.h> 
struct MyData
{
    public:
    int Addition(int a, int b = 10)
    {
        return (a *= b + 2);
    }
    float Addition(int a, float b);
};
int main()
{
    MyData data;
    cout<<data.Addition(1)<<" ";
    cout<<data.Addition(3, 4);
    return 0; 
}
12 12
12 18
3 14
18 12
Compilation fails.
Your Answer: Option
(Not Answered)
Correct Answer: Option

11.
Which of the following statements is correct?
  1. Once the variable and the reference are linked they are tied together.
  2. Once the reference of a variable is declared another reference of that variable is not allowed.
Only 1 is correct.
Only 2 is correct.
Both 1 and 2 are correct.
Both 1 and 2 are incorrect.
Your Answer: Option
(Not Answered)
Correct Answer: Option

12.
Which of the following statement is correct?
An array of references is acceptable.
Once a reference variable has been defined to refer to a particular variable it can refer to any other variable.
An array of references is not acceptable.
Reference is like a structure.
Your Answer: Option
(Not Answered)
Correct Answer: Option

13.
Which of the following statement is correct?
A reference is a constant pointer.
A reference is not a constant pointer.
An array of references is acceptable.
It is possible to create a reference to a reference.
Your Answer: Option
(Not Answered)
Correct Answer: Option

14.
Which of the following statement is correct with respect to the use of friend keyword inside a class?
A private data member can be declared as a friend.
A class may be declared as a friend.
An object may be declared as a friend.
We can use friend keyword as a class name.
Your Answer: Option
(Not Answered)
Correct Answer: Option

15.
Which of the following statements is correct?
Data items in a class must be private.
Both data and functions can be either private or public.
Member functions of a class must be private.
Constructor of a class cannot be private.
Your Answer: Option
(Not Answered)
Correct Answer: Option

16.
Which of the following means "The use of an object of one class in definition of another class"?
Encapsulation
Inheritance
Composition
Abstraction
Your Answer: Option
(Not Answered)
Correct Answer: Option

17.
Which of the following statement is correct about destructors?
A destructor has void return type.
A destructor has integer return type.
A destructor has no return type.
A destructors return type is always same as that of main().
Your Answer: Option
(Not Answered)
Correct Answer: Option

18.
When are the Global objects destroyed?
When the control comes out of the block in which they are being used.
When the program terminates.
When the control comes out of the function in which they are being used.
As soon as local objects die.
Your Answer: Option
(Not Answered)
Correct Answer: Option

19.
Destructor has the same name as the constructor and it is preceded by ______ .
!
?
~
$
Your Answer: Option
(Not Answered)
Correct Answer: Option

20.
How many default constructors per class are possible?
Only one
Two
Three
Unlimited
Your Answer: Option
(Not Answered)
Correct Answer: Option

*** END OF THE TEST ***
Time Left: 00:29:56
Post your test result / feedback here: