C++ MCQs with answers Page - 54

Here, you will find a collection of MCQ questions on C++. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 833.24K Points
Coach

Q. Which of the following statement is correct?

  • (A) C++ allows static type checking.
  • (B) C++ allows dynamic type checking.
  • (C) C++ allows static member function be of type const
  • (D) Both A and B.

A

Admin • 833.24K Points
Coach

Q. Which of the following factors supports the statement that reusability is a desirable feature of a language?

  • (A) It decreases the testing time.
  • (B) It lowers the maintenance cost.
  • (C) It reduces the compilation time.
  • (D) Both A and B.

A

Admin • 833.24K Points
Coach

Q. 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

A

Admin • 833.24K Points
Coach

Q. What would be the output of the following program (in 32-bit systems)?

Code:
#include 
using namespace std;
    int main()
    {
        cout << sizeof(char);
        cout << " "<< sizeof(int);
        cout << " "<< sizeof(float);
        return 0;
    }
  • (A) 1 4 4
  • (B) 4 4 1
  • (C) 4 1 4
  • (D) Garbage value

A

Admin • 833.24K Points
Coach

Q. What is the output of the following program?

Code:
#include 
using namespace std;
    int main()
    {
        int p = 10;
        float q;
        cout << sizeof(++p + q);
        cout << " "<        return 0;
    }
  • (A) 10 2
  • (B) 10 4
  • (C) 2 10
  • (D) 4 10

A

Admin • 833.24K Points
Coach

Q. Identify the incorrect option.

  • (A) sizeof(char) <= sizeof(long) <=sizeof(wchar_t)
  • (B) 1 <= sizeof(bool) <= sizeof(long)
  • (C) sizeof(N) = sizeof(signed N) = sizeof(unsigned N)
  • (D) sizeof(float) <= sizeof(double) <= sizeof(long double)

A

Admin • 833.24K Points
Coach

Q. Size of C++ objects are expressed in terms of multiples of the size of a ____ and the size of a char is _______

  • (A) char, 4
  • (B) float, 8
  • (C) int, 1
  • (D) char, 1

A

Admin • 833.24K Points
Coach

Q. It is guaranteed that a ____ has at least 8 bits and a ____ has at least 16 bits.

  • (A) bool, char
  • (B) int, float
  • (C) char, short
  • (D) char, int

A

Admin • 833.24K Points
Coach

Q. The size of an object or a type can be determined using which operator?

  • (A) sizeof
  • (B) malloc
  • (C) calloc
  • (D) malloc

A

Admin • 833.24K Points
Coach

Q. Which is correct with respect to size of the data types?

  • (A) char < int < double
  • (B) char < int < float
  • (C) int < char > float
  • (D) char > int < float