CPA practice question 29 of 30

What is the output of the program? #include #include using namespace std; class First { string name; public: First() { name = "Alan"; } void setName(string n) {this?>name = n;} void setName() {this?>name = "John";} void Print(){ cout setName(); t?>Print(); t = ob2; t?>setName("Steve"); ob2?>Print(); }

Full set: 220 questions
Answer options
A: It prints: JohnSteve Correct answer
B: It prints: AlanAlan
C: It prints: AlanSteve
D: It prints: JohnAlan
Correct Answer:
A. It prints: JohnSteve
Scroll to Top