Which of the following is the output of the following C++ code segment in Dev…

PYQ DSSSB 2022

Which of the following is the output of the following C++ code segment in Dev C++ under Windows 10 operating system?

#include <iostream>
using namespace std;

class A {
    int a = 10, b = 20;
    A(int a, int b) { a = 30; b = 40; }
public:
    A() {
        A x(50, 60);
        cout << "a=" << a << " b=" << b;
    }
};

int main() {
    A y;
}
  1. A.

    a=30 b=40

  2. B.

    a=10 b=20

  3. C.

    a=50 b=60

  4. D.

    a=10 b=60

Attempted by 862 students.

Sign up free to check your answer

Sign up free

Explore the full course: Dsssb Tgt Computer Science Paper 2

Loading lesson…