Online Test for C++

  1. Find Error/Output in follwing code:
  2.                                 
    #include <iostream>  
    
    using namespace std;  

    void square (int *x)  {
        *x = (*x)++ * (*x);  


    void square (int *x, int *y) {
        *x = (*x) * --(*y); 


    int main ( ) {
        int number = 30;          
        square(&number, &number);           
        cout << number;           
        return 0;  
    }
    910
    920
    870
    900

  1. Which of the following is not a member of class?
    Static function
    Friend function
    Const function
    Virtual function


  1. Which of the following operator(s) cannot be overloaded?
    . (Member Access or Dot operator)
    ?: (Ternary or Conditional Operator )
    :: (Scope Resolution Operator)
    All of the above

  1. When a method in a subclass has the same name and type signatures as a method in the superclass, then the method in the subclass _____ the method in the super class.
    Overloads
    Friendships
    Inherits
    Overrides

  1. Which of the following operators can not be overloaded in C+ +?
    *
    ==
    +=
    ::

  1. The static member variable is initialized to?
    0
    1
    2
    -1


  1. What is pointer?
    The variable that stores the reference to another variable
    The variable that stores reference of garbage variable
    The variable that stores the memory address of another variable
    A & C Both

  1. A __________ is a special method used to initialize the instance variable of a class.
    Member function
    Destructor
    Constructor
    Structure

  1. Which of the following storage classes have global visibility in C++?
    Register
    Static
    Auto
    Extern

  1. Super classes are also called Parent classes/Base classes.
    True
    False

Post Your Question
Social Sharing
Search