Programming Practices Using C++

70 Questions | Total Attempts: 653

SettingsSettingsSettings
Programming Practices Using C++ - Quiz

Questions and Answers
  • 1. 
    Which of the following type of class allows only one object of it to be created?
    • A. 

      Virtual class

    • B. 

      Abstract class

    • C. 

      Singleton class

    • D. 

      Friend class

  • 2. 
    Which of the following is not a type of constructor?
    • A. 

      Copy constructor

    • B. 

      Friend constructor

    • C. 

      Default constructor

    • D. 

      Parameterized constructor

  • 3. 
    Which of the following is an invalid visibility label while inheriting a class?
    • A. 

      Public

    • B. 

      Private

    • C. 

      Protected

    • D. 

      Friend

  • 4. 
    Which of the following statements is correct in C++?
    • A. 

      Class members are public by default.

    • B. 

      Structure members are private by default.

    • C. 

      Structures can have functions as members.

    • D. 

      Classes cannot have data as protected members.

  • 5. 
    Which of the following provides a reuse mechanism?
    • A. 

      Abstraction

    • B. 

      Inheritance

    • C. 

      Dynamic binding

    • D. 

      Encapsulation

  • 6. 
    Which of the following cannot be used with the keyword virtual?
    • A. 

      Class

    • B. 

      Member functions

    • C. 

      Constructor

    • D. 

      Destructor

  • 7. 
    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.
    • A. 

      Inheritance

    • B. 

      Polymorphism

    • C. 

      Abstraction

    • D. 

      Encapsulation

  • 8. 
    Which of the following problem causes an exception?
    • A. 

      Missing semicolon in statement in main().

    • B. 

      A problem in calling function.

    • C. 

      A run-time error.

    • D. 

      A syntax error.

  • 9. 
    Which of the following concepts is used to implement late binding?
    • A. 

      Virtual function

    • B. 

      Operator function

    • C. 

      Const function

    • D. 

      Static function

  • 10. 
    Which of the following ways are legal to access a class data member using this pointer?
    • A. 

      This->x

    • B. 

      This.x

    • C. 

      *this.x

    • D. 

      *this-x

  • 11. 
    Which of the following operators cannot be overloaded?
    • A. 

      [ ]

    • B. 

      ->

    • C. 

      ?:

    • D. 

      *

  • 12. 
    Which one of the following is the correct way to declare a pure virtual function?
    • A. 

      Virtual void Display(void){0};

    • B. 

      Virtual void Display = 0;

    • C. 

      Void Display(void) = 0;

    • D. 

      Virtual void Display(void) = 0;

  • 13. 
    Which of the following correctly describes overloading of functions?
    • A. 

      Virtual polymorphism

    • B. 

      Transient polymorphism

    • C. 

      Ad-hoc polymorphism

    • D. 

      Pseudo polymorphism

  • 14. 
    Which of the following approach is adapted by C++?
    • A. 

      Top-down

    • B. 

      Left-right

    • C. 

      Bottom-up

    • D. 

      Right-left

  • 15. 
    Which of the following keyword is used to overload an operator?
    • A. 

      Operator

    • B. 

      Overload

    • C. 

      Friend

    • D. 

      Override

  • 16. 
    Which inheritance type is used in the class given below? class A : public X, public Y {}
    • A. 

      Multilevel inheritance

    • B. 

      Multiple inheritance

    • C. 

      Hybrid inheritance

    • D. 

      Hierarchical Inheritance

  • 17. 
    How many types of polymorphisms are supported by C++?
    • A. 

      1

    • B. 

      2

    • C. 

      3

    • D. 

      4

  • 18. 
    Destructor has the same name as the constructor and it is preceded by ______ .
    • A. 

      !

    • B. 

      ?

    • C. 

      ~

    • D. 

      $

  • 19. 
    If the copy constructor receives its arguments by value, the copy constructor would
    • A. 

      Call one-argument constructor of the class

    • B. 

      Work without any problem

    • C. 

      Call itself recursively

    • D. 

      Call zero-argument constructor

  • 20. 
    Which of the following implicitly creates a default constructor when the programmer does not explicitly define at least one constructor for a class?
    • A. 

      Linker

    • B. 

      Preprocessor

    • C. 

      Compiler

    • D. 

      Loader

  • 21. 
    Which of the following never requires any arguments?
    • A. 

      Member function

    • B. 

      Friend function

    • C. 

      Const function

    • D. 

      Default constructor

  • 22. 
    To ensure that every object in the array receives a destructor call, always delete memory allocated as an array with operator __________ .
    • A. 

      Delete[ ]

    • B. 

      Delete

    • C. 

      Kill[ ]

    • D. 

      Free[ ]

  • 23. 
    Which of the following function prototype is perfectly acceptable?
    • A. 

      Int Function(int Tmp = Show());

    • B. 

      Float Function(int Tmp = Show(int, float));

    • C. 

      Float = Show(int, float) Function(Tmp);

    • D. 

      None of these

  • 24. 
    Which of the following statement will be correct if the function has three arguments passed to it?
    • A. 

      The trailing argument will be the default argument.

    • B. 

      The first argument will be the default argument.

    • C. 

      The middle argument will be the default argument.

    • D. 

      All the argument will be the default argument.

  • 25. 
    Which of the following statement is correct?
    • A. 

      Only one parameter of a function can be a default parameter.

    • B. 

      Minimum one parameter of a function must be a default parameter.

    • C. 

      All the parameters of a function can be default parameters.

    • D. 

      No parameter of a function can be default.

Back to Top Back to top