Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute Exam CPA-21-02 Topic 1 Question 24 Discussion

Actual exam question for C++ Institute's CPA-21-02 exam
Question #: 24
Topic #: 1
[All CPA-21-02 Questions]

What happens when you attempt to compile and run the following code?

#include

using namespace std;

class First

{

public:

void Print(){ cout<<"from First";}

};

class Second

{

public:

void Print(){ cout<< "from Second";}

};

int main()

{

First FirstObject;

FirstObject.Print();

Second SecondObject;

SecondObject.Print();

}

Show Suggested Answer Hide Answer
Suggested Answer: D

Contribute your Thoughts:

Johna
3 days ago
I agree with Esteban, the code will print from First and then from Second.
upvoted 0 times
...
Chauncey
5 days ago
The correct answer is option C. The code will print 'from Firstfrom Second' because it creates two objects, one of the 'First' class and one of the 'Second' class, and then calls the 'Print()' method on each object.
upvoted 0 times
...
Esteban
14 days ago
I think it will print from First first and then from Second.
upvoted 0 times
...

Save Cancel