Online C++ Programming Test - C++ Programming Test - Random

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?
C++ allows static type checking.
C++ allows dynamic type checking.
C++ allows static member function be of type const.
Both A and B.
Your Answer: Option
(Not Answered)
Correct Answer: Option

2.
How many types of polymorphisms are supported by C++?
1
2
3
4
Your Answer: Option
(Not Answered)
Correct Answer: Option
Explanation:
The two main types of polymorphism are run-time (implemented as inheritance and virtual functions), and compile-time (implemented as templates).

3.
Which one of the following is correct about the statements given below?
  1. All function calls are resolved at compile-time in Procedure Oriented Programming.
  2. All function calls are resolved at compile-time in OOPS.
Only II is correct.
Both I and II are correct.
Only I is correct.
Both I and II are incorrect.
Your Answer: Option
(Not Answered)
Correct Answer: Option

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

5.
Which one of the following options is correct about the statement given below? The compiler checks the type of reference in the object and not the type of object.
Inheritance
Polymorphism
Abstraction
Encapsulation
Your Answer: Option
(Not Answered)
Correct Answer: Option

6.
Which of the following statement is incorrect?
Default arguments can be provided for pointers to functions.
A function can have all its arguments as default.
Default argument cannot be provided for pointers to functions.
A default argument cannot be redefined in later declaration.
Your Answer: Option
(Not Answered)
Correct Answer: Option

7.
Which of the following statement is correct?
Only one parameter of a function can be a default parameter.
Minimum one parameter of a function must be a default parameter.
All the parameters of a function can be default parameters.
No parameter of a function can be default.
Your Answer: Option
(Not Answered)
Correct Answer: Option

8.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
static double gDouble; 
static float  gFloat; 
static double gChar; 
static double gSum = 0; 
class BaseOne
{
    public:
    void Display(double x = 0.0, float y = 0.0, char z = 'A')
    {
        gDouble = x;
        gFloat  = y;
        gChar   = int(z);
        gSum    = gDouble + gFloat + gChar;
        cout << gSum; 
    }
};
class BaseTwo
{
    public: 
    void Display(int x = 1, float y = 0.0, char z = 'A')
    {
        gDouble = x;
        gFloat  = y;
        gChar   = int(z); 
        gSum    = gDouble + gFloat + gChar;
        cout << gSum;
    }
};
class Derived : public BaseOne, BaseTwo
{
    void Show()
    {
        cout << gSum;
    } 
}; 
int main()
{
    Derived objDev;
    objDev.BaseTwo::Display(10, 20, 'Z');
    return 0; 
}
The program will print the output 0.
The program will print the output 120.
The program will report run-time error.
The program will report compile-time error.
The program will print the output garbage value.
Your Answer: Option
(Not Answered)
Correct Answer: Option

9.
Which of the following statements is correct?
  1. Once a reference variable has been defined to refer to a particular variable it can refer to any other variable.
  2. A reference is not a constant pointer.
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

10.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
int main()
{
    int arr[] = {1, 2 ,3, 4, 5}; 
    int &zarr = arr;
    for(int i = 0; i <= 4; i++)
    {
        arr[i] += arr[i];
    }
    for(i = 0; i <= 4; i++)
        cout<< zarr[i]; 
    return 0; 
}
The program will print the output 1 2 3 4 5.
The program will print the output 2 4 6 8 10.
The program will print the output 1 1 1 1 1.
It will result in a compile time error.
Your Answer: Option
(Not Answered)
Correct Answer: Option

11.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
class IndiaBix
{
    int x, y; 
    public:
    IndiaBix(int &xx, int &yy)
    {
        x = xx;
        y = yy;
        Display();
    }
    void Display()
    {
        cout<< x << " " << y;
    }
};
int main()
{
    int x1 = 10; 
    int &p = x1;
    int y1 = 20; 
    int &q = y1; 
    IndiaBix objBix(p, q); 
    return 0; 
}
It will result in a compile time error.
The program will print the output 10 20.
The program will print two garbage values.
The program will print the address of variable x1 and y1.
Your Answer: Option
(Not Answered)
Correct Answer: Option

12.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
enum xyz
{
    a, b, c
};
int main() 
{
    int x = a, y = b, z = c;
    int &p = x, &q = y, &r = z;
    p = ++x;
    q = ++y;
    r = ++c;
    cout<< p << q << r;
    return 0;
}
The program will print the output 1 2 3.
The program will print the output 2 3 4.
The program will print the output 0 1 2.
It will result in a compile time error.
Your Answer: Option
(Not Answered)
Correct Answer: Option

13.
Which of the following statements about virtual base classes is correct?
It is used to provide multiple inheritance.
It is used to avoid multiple copies of base class in derived class.
It is used to allow multiple copies of base class in a derived class.
It allows private members of the base class to be inherited in the derived class.
Your Answer: Option
(Not Answered)
Correct Answer: Option

14.
Which of the following can be overloaded?
Object
Functions
Operators
Both B and C
Your Answer: Option
(Not Answered)
Correct Answer: Option

15.
Which of the following statement is correct about the program given below?
#include<iostream.h>
#include<string.h> 
class IndiaBix
{
    public:
    void GetData(char *s, int x, int y )
    {
        int i = 0;
        for (i = x-1; y>0; i++)
        {
            cout<< s[i];
            y--; 
        } 
    }
}; 
int main()
{
    IndiaBix objBix;
    objBix.GetData((char*)"Welcome!", 1, 3);
    return 0; 
}
The program will print the output me!.
The program will print the output Wel.
The program will print the output !em.
The program will print the output Welcome!.
The program will result in a compile time error.
Your Answer: Option
(Not Answered)
Correct Answer: Option

16.
A constructor that accepts __________ parameters is called the default constructor.
one
two
no
three
Your Answer: Option
(Not Answered)
Correct Answer: Option

17.
Which of the following cannot be declared as virtual?
Constructor
Destructor
Data Members
Both A and C
Your Answer: Option
(Not Answered)
Correct Answer: Option

18.
How many times a constructor is called in the life-time of an object?
Only once
Twice
Thrice
Depends on the way of creation of object
Your Answer: Option
(Not Answered)
Correct Answer: Option

19.
Which of the following statement is incorrect?
Constructor is a member function of the class.
The compiler always provides a zero argument constructor.
It is necessary that a constructor in a class should always be public.
Both B and C.
Your Answer: Option
(Not Answered)
Correct Answer: Option

20.
Can a class have virtual destructor?
Yes
No
Your Answer: Option
(Not Answered)
Correct Answer: Option

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