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 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
14 days ago
I love how they try to make these questions so tricky. 'Protected' all the way, baby!
upvoted 0 times
...
Andra
18 days ago
Haha, 'None of these'? Seriously? They're just trying to trick us, aren't they?
upvoted 0 times
Esteban
4 days ago
B) private
upvoted 0 times
...
Freeman
7 days ago
A) public
upvoted 0 times
...
...
Meghann
25 days ago
Of course it's 'protected'! What else could it be? I could do this in my sleep.
upvoted 0 times
Merlyn
2 days ago
Of course it's 'protected'! What else could it be? I could do this in my sleep.
upvoted 0 times
...
Marget
4 days ago
D) None of these
upvoted 0 times
...
Benedict
7 days ago
C) protected
upvoted 0 times
...
Vilma
8 days ago
B) private
upvoted 0 times
...
Billy
14 days ago
A) public
upvoted 0 times
...
...
Barrie
1 months ago
Hmm, I'm pretty sure the answer is 'C) protected'. That's how inheritance works, you know.
upvoted 0 times
...
Chandra
1 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
9 days ago
C) protected
upvoted 0 times
...
Dona
16 days ago
B) private
upvoted 0 times
...
Bea
25 days ago
A) public
upvoted 0 times
...
...
Minna
2 months ago
I agree with Pearlie. Since class B is inheriting from class A, 'y' will remain protected.
upvoted 0 times
...
Pearlie
2 months ago
I think variable 'y' will be protected in class B.
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