Skip to main content

Create a program in C# by using Vehicle Car and Truck as a classes and implement polymorphism in it.

using System;

    public class Program
        static void Main(string[] args)
            Vehicle vehicle = new Vehicle();
            Vehicle vehicle1 = new Car();
            Vehicle vehicle2 = new Truk();





    public class Vehicle
        public virtual void start() { Console.WriteLine("Vehicle Started"); }
        public virtual void horn() { Console.WriteLine("Vehicle Horned"); }
        public virtual void stop() { Console.WriteLine("Vehicle Stopped"); }

    public class Car : Vehicle
        public override void start() { Console.WriteLine("Car Started"); }
        public override void horn() { Console.WriteLine("Car Horned"); }
        public override void stop() { Console.WriteLine("Car Stopped"); }
    public class Truk : Vehicle
        public override void start() { Console.WriteLine("Truck Started"); }
        public override void horn() { Console.WriteLine("Truck Horned"); }
        public override void stop() { Console.WriteLine("Truck Stopped"); }



  1. Replies
    1. A IEEE project is an interrelated arrangement of exercises, having a positive beginning and end point and bringing about an interesting result in Engineering Colleges for a particular asset assignment working under a triple limitation - time, cost and execution. Final Year Project Domains for CSE In Engineering Colleges, final year IEEE Project Management requires the utilization of abilities and information to arrange, plan, plan, direct, control, screen, and assess a final year project for cse. The utilization of Project Management to accomplish authoritative objectives has expanded quickly and many engineering colleges have reacted with final year IEEE projects Project Centers in Chennai for CSE to help students in learning these remarkable abilities.

      Spring Framework has already made serious inroads as an integrated technology stack for building user-facing applications. Spring Framework Corporate TRaining the authors explore the idea of using Java in Big Data platforms.
      Specifically, Spring Framework provides various tasks are geared around preparing data for further analysis and visualization. Spring Training in Chennai

  2. I really like your post. I found it very helpful. Please keep posting such kind of valuable post.
    C++ Course in Delhi

  3. I read your post and got it quite informative. I couldn't find any knowledge on this matter prior to. I would like to thanks for sharing this article here. Best C++ With Data Structures Course In Delhi


Post a Comment