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 5 Question 20 Discussion

Actual exam question for C++ Institute's CPA-21-02 exam
Question #: 20
Topic #: 5
[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:

Myra
13 days ago
Ugh, I hate these inheritance questions! But I think I've got this one. Since 'y' is protected in class A, it will be protected in class B too. The answer is C) protected.
upvoted 0 times
...
Dante
15 days ago
This is a classic inheritance question. If 'y' is protected in class A, then it will be protected in class B as well. The answer is definitely C) protected.
upvoted 0 times
...
Cassandra
16 days ago
Haha, this is a tricky one! I bet the professor is trying to trip us up. But if we remember the rules of inheritance, the answer has to be C) protected.
upvoted 0 times
Lovetta
2 days ago
I think you're right, it has to be C) protected.
upvoted 0 times
...
Dick
3 days ago
So, variable 'y' in class B would be protected.
upvoted 0 times
...
Alpha
8 days ago
Yeah, I remember learning that protected variables are accessible by derived classes.
upvoted 0 times
...
Bambi
9 days ago
I think you're right, it has to be C) protected.
upvoted 0 times
...
...
Jessenia
20 days ago
I think the correct answer is C) protected, as 'y' is accessible within the derived class B.
upvoted 0 times
...
Michael
21 days ago
I believe the answer is C) protected, as 'y' is inherited from class A.
upvoted 0 times
...
Arlen
22 days ago
I agree with Queen, because class B inherits from class A.
upvoted 0 times
...
Nickolas
24 days ago
Hmm, I'm not sure about this one. Since class B inherits publicly from class A, wouldn't 'y' be accessible in class B as well? I think the answer might be A) public.
upvoted 0 times
Teddy
5 days ago
Exactly, the answer is A) public.
upvoted 0 times
...
Carin
6 days ago
So, the answer would be A) public then.
upvoted 0 times
...
Erasmo
9 days ago
Yes, that's correct. 'y' would be accessible in class B.
upvoted 0 times
...
Tamekia
18 days ago
I think 'y' would be accessible in class B since it inherits publicly from class A.
upvoted 0 times
...
...
Queen
1 months ago
I think variable 'y' will be protected in class B.
upvoted 0 times
...
Lindsay
2 months ago
Well, the question clearly states that 'y' is a protected member in class A, so the answer has to be C) protected.
upvoted 0 times
Melinda
19 days ago
User 4: Got it, thanks for clarifying.
upvoted 0 times
...
Leonida
23 days ago
User 3: Yes, because 'y' is a protected member in class A.
upvoted 0 times
...
Yuki
1 months ago
User 2: Are you sure about that?
upvoted 0 times
...
Elza
1 months ago
User 1: The answer is C) protected.
upvoted 0 times
...
...

Save Cancel