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:

Jerrod
14 days ago
Wait, are we supposed to actually compile and run this code? I thought this was just a theoretical question. I'm going to try it out and see what happens!
upvoted 0 times
...
Mammie
16 days ago
This is a great question! It really tests your understanding of C++ and class inheritance. I'm glad I studied this topic thoroughly.
upvoted 0 times
Cherri
1 days ago
A) It prints: from First
upvoted 0 times
...
...
Francine
1 months ago
Haha, this question is a classic! It's testing whether you understand how object-oriented programming works. I bet the person who wrote this question is a real joker.
upvoted 0 times
Vernice
15 days ago
No, it actually prints: from First from First
upvoted 0 times
...
Arletta
20 days ago
I think it prints: from First from Second
upvoted 0 times
...
...
Miesha
1 months ago
I'm not sure, but I think it will print from First twice.
upvoted 0 times
...
Carlee
1 months ago
I agree with Chauncey. The code is straightforward, and the output is exactly what I would expect.
upvoted 0 times
Glenn
2 days ago
I agree with you, it should be: from First from Second
upvoted 0 times
...
Bobbie
16 days ago
Yes, that's correct. The code creates objects of both classes and calls their Print functions.
upvoted 0 times
...
Billye
19 days ago
No, it will print: from First from First
upvoted 0 times
...
Bobbie
23 days ago
I think it will print: from First and then from Second.
upvoted 0 times
...
Xuan
27 days ago
I think the output will be: from First from Second
upvoted 0 times
...
...
Johna
2 months ago
I agree with Esteban, the code will print from First and then from Second.
upvoted 0 times
...
Chauncey
2 months 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
Geraldine
18 days ago
D) It prints: from Secondfrom Second
upvoted 0 times
...
Britt
1 months ago
C) It prints: from Firstfrom Second
upvoted 0 times
...
Leila
1 months ago
B) It prints: from Firstfrom First
upvoted 0 times
...
Gearldine
1 months ago
A) It prints: from First
upvoted 0 times
...
...
Esteban
2 months ago
I think it will print from First first and then from Second.
upvoted 0 times
...

Save Cancel