Please login to save your progress.
Inheritance
Exercise: Use the virtual and override keywords
Goal
- Create an abstract class named Astrodroid that provides a virtual method called GetSound which returns a string. The default sound should be the words "Beep beep".
- Implement a method called 'MakeSound' which writes the result of the GetSound method to the Console followed by a new line.
- Create a derived class named R2 that inherits from Astrodroid.
- Override the GetSound method on the R2 class so that it returns "Beep bop".
x
1
using System;
2
3
// Implement your classes here.
4
5
public class Program
6
{
7
public static void Main()
8
{
9
10
}
11
}
Page 15 of 18