New Year Sale ! 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 2 Question 30 Discussion

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

What will variable "y" be in class B?

class A {

int x;

protected:

int y;

public:

int age;

};

class B : public A {

string name;

public:

void Print() {

cout << name << age;

}

};

Show Suggested Answer Hide Answer
Suggested Answer: C

Contribute your Thoughts:

Ria
2 months ago
I love how they try to make these questions so tricky. 'Protected' all the way, baby!
upvoted 0 times
Miesha
21 days ago
Definitely protected, no doubt about it.
upvoted 0 times
...
Miesha
23 days ago
I agree, 'protected' is the correct answer.
upvoted 0 times
...
Miesha
29 days ago
I think it will be protected.
upvoted 0 times
...
...
Andra
2 months ago
Haha, 'None of these'? Seriously? They're just trying to trick us, aren't they?
upvoted 0 times
Derick
15 days ago
They're definitely trying to test our understanding of inheritance.
upvoted 0 times
...
Keva
16 days ago
D) None of these
upvoted 0 times
...
Marshall
17 days ago
C) protected
upvoted 0 times
...
Esteban
1 months ago
B) private
upvoted 0 times
...
Freeman
1 months ago
A) public
upvoted 0 times
...
...
Meghann
2 months ago
Of course it's 'protected'! What else could it be? I could do this in my sleep.
upvoted 0 times
Merlyn
1 months ago
Of course it's 'protected'! What else could it be? I could do this in my sleep.
upvoted 0 times
...
Marget
1 months ago
D) None of these
upvoted 0 times
...
Benedict
1 months ago
C) protected
upvoted 0 times
...
Vilma
1 months ago
B) private
upvoted 0 times
...
Billy
1 months ago
A) public
upvoted 0 times
...
...
Barrie
2 months ago
Hmm, I'm pretty sure the answer is 'C) protected'. That's how inheritance works, you know.
upvoted 0 times
...
Chandra
2 months ago
The variable 'y' will be 'protected' in class B, since it is declared as 'protected' in the base class A.
upvoted 0 times
Luisa
1 months ago
C) protected
upvoted 0 times
...
Dona
2 months ago
B) private
upvoted 0 times
...
Bea
2 months ago
A) public
upvoted 0 times
...
...
Minna
3 months ago
I agree with Pearlie. Since class B is inheriting from class A, 'y' will remain protected.
upvoted 0 times
...
Pearlie
3 months ago
I think variable 'y' will be protected in class B.
upvoted 0 times
...

Save Cancel