1. //program to inherit a class Dog from class Animal using System; public class Animal { public void eat() { Console.WriteLine("Eating..."); } } public class Dog : Animal { public void bark() { Console.WriteLine("Barking..."); } } class TestInheritance2 { public static void Main(string[] args) { Dog d1 = new Dog(); d1.eat(); d1.bark(); Console.ReadLine(); } } 2. //program to inherit a class Car from class Vehicle using System; class Vehicle // base class (parent) { public string brand = "Ford"; // Vehicle field public void honk() // Vehicle method { Console.WriteLine("Tuut, tuut!"); } } class Car : Vehicle // derived class (child) { public string modelName = "Mustang"; // Car field } class Program { static void Main(string[] args) { // Create a myCar object Car myCar = new Car(); // Call the honk() method (From the Vehicle class) on the myCar object myCar.honk(); // Display the value of the brand field (from the Vehicle class) and the value of the modelName from the Car class Console.WriteLine(myCar.brand + " " + myCar.modelName); Console.ReadLine(); } }