Access Control in Inheritance

Hands-on practice for this lecture. Work through the exercises and quizzes to reinforce what you've learned.

1

Exercise 1 of 1

The Inheritance Mystery: Memory vs Visibility

Solve the riddle of private attributes in inheritance. Do they really get passed down if you can't see them?

Do private attributes of a Parent class occupy space in the memory of a Child object?

If a Parent has a 4-byte private 'id' and the Child adds a 4-byte 'score', how big is the Child object?

🕵️ The 16-Byte Mystery: Visibility and Memory are two different things. A child inherits the whole body of the parent, including the private parts it can't see.

Practice: Access Control in Inheritance — Interactive Exercises | Durgesh Rai