New Year Sale 2026! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

C++ Institute CPA-21-02 Exam - Topic 2 Question 48 Discussion

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

What is the output of the program?

#include

#include

using namespace std;

union t

{

char c;

int i;

};

class First

{

union t u;

public:

First() {

u.c = 'A';

}

void Print(){

cout << u.c;

}

};

int main()

{

First *t = new First();

t?>Print();

}

Show Suggested Answer Hide Answer
Suggested Answer: B

Contribute your Thoughts:

0/2000 characters
Kenneth
4 days ago
Hmm, I'm not sure about this one. Could be B or C.
upvoted 0 times
...
Kimberlie
9 days ago
I'm pretty sure the answer is B. It prints 'A'.
upvoted 0 times
...
Irma
14 days ago
The output should be 'A'.
upvoted 0 times
...
Laurel
19 days ago
I feel like there might be a compilation error due to the way the Print function is called with the arrow operator.
upvoted 0 times
...
Billi
25 days ago
I practiced a similar question, and I think it should print 'A' because the Print function directly accesses the character.
upvoted 0 times
...
Danica
30 days ago
I'm not sure, but I remember something about unions that might cause a garbage value if not handled properly.
upvoted 0 times
...
Cordie
1 month ago
I think the output should be 'A' since the constructor initializes the union with 'A'.
upvoted 0 times
...
Beatriz
1 month ago
I've got it! The union will store the 'A' character, but when we print it, it will print the ASCII value 65 instead of just the character. The answer is C.
upvoted 0 times
...
Tyra
2 months ago
I'm not sure about this one. The question mentions "output of the program", so it might be related to how the program is executed, not just the union.
upvoted 0 times
...
Paulene
2 months ago
Okay, let me think this through. The union has a char and an int member, and the First class initializes the char member to 'A'. So the output should be just 'A'.
upvoted 0 times
...
Joesph
2 months ago
Hmm, I'm a bit confused about unions. Do they store multiple values at the same time or just one?
upvoted 0 times
...
Royce
2 months ago
I think I can handle this one. The key is understanding how unions work in C++.
upvoted 0 times
...

Save Cancel