Inheritance (Exercise) – Learn C#

0  comments

When you look into a dictionary, the verb inherit means to derive a quality from parents or ancestors. You know, your mom was tall, your dad was tall and you are likely to be tall too. This is exactly what inheritance does even in programming! It’s nothing scary, just instead of a child who inherits the traits of its parents, you have a subclass which inherits members from its base class.

This is an exercise for this YouTube video.

Happy learning and good luck!

 

Which keyword allows a method in the base class to be overriden in its subclass?
What is the keyword "new" used for? (Choose the most correct answer)

 

Assignment: Create an Animal class with one method for making sound. Then create a Dog and a Cat (which derive from Animal) and make them bark or meow respectively.

Click to see the answer

 

 

 

 

About the author 

Matt Rešetár

Matt is an app developer with a knack for teaching others. Working as a Flutter freelancer and most importantly developer educator, he doesn't have a lot of free time 😅 Yet he still manages to squeeze in tough workouts 💪

You may also like

Flutter Bloc & Cubit Tutorial

Flutter Custom & Staggered Page Transition Animation Tutorial

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
>