Cyber Monday 2024! 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
4 months 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
4 months 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
4 months 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
3 months ago
Yeah, I remember that from class. C) protected makes sense.
upvoted 0 times
...
Lovetta
4 months ago
I think you're right, it has to be C) protected.
upvoted 0 times
...
Dick
4 months ago
So, variable 'y' in class B would be protected.
upvoted 0 times
...
Alpha
4 months ago
Yeah, I remember learning that protected variables are accessible by derived classes.
upvoted 0 times
...
Bambi
4 months ago
I think you're right, it has to be C) protected.
upvoted 0 times
...
...
Jessenia
4 months ago
I think the correct answer is C) protected, as 'y' is accessible within the derived class B.
upvoted 0 times
...
Michael
4 months ago
I believe the answer is C) protected, as 'y' is inherited from class A.
upvoted 0 times
...
Arlen
4 months ago
I agree with Queen, because class B inherits from class A.
upvoted 0 times
...
Nickolas
4 months 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
4 months ago
Exactly, the answer is A) public.
upvoted 0 times
...
Carin
4 months ago
So, the answer would be A) public then.
upvoted 0 times
...
Erasmo
4 months ago
Yes, that's correct. 'y' would be accessible in class B.
upvoted 0 times
...
Tamekia
4 months ago
I think 'y' would be accessible in class B since it inherits publicly from class A.
upvoted 0 times
...
...
Queen
5 months ago
I think variable 'y' will be protected in class B.
upvoted 0 times
...
Lindsay
5 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
4 months ago
Got it, thanks for clarifying.
upvoted 0 times
...
Leonida
4 months ago
Yes, because 'y' is a protected member in class A.
upvoted 0 times
...
Yuki
5 months ago
Are you sure about that?
upvoted 0 times
...
Elza
5 months ago
The answer is C) protected.
upvoted 0 times
...
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77