Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8925723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:46:35+00:00 2026-06-15T07:46:35+00:00

Possible Duplicate: Try to describe polymorphism as easy as you can I have trouble

  • 0

Possible Duplicate:
Try to describe polymorphism as easy as you can

I have trouble understanding what exactly polymorphism is?
And for example how would this code use polymorphism

I have a car class and a method inside that called countprice and i also have a jeep class that inherits from the car class.

List<Car> carlist = new List<Car>();
Jeep jeepABC123 = new Jeep(800, 14, 20, 10, 3500);
carlist.Add(jeepABC123);
Sedan sedanGHA321 = new Sedan(600, 7, 20, 10);
carlist.Add(sedanGHA321)

// This code
foreach (Bil bil in carlist)
{
revenue = revenue + car.countprice();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:46:36+00:00Added an answer on June 15, 2026 at 7:46 am

    It’s simple, you can put Jeeps into your array of Cars

    Maybe you can also implement Truck which would inherit from Car, then your carlist can have both Jeeps and Trucks in it at the same time.

    Polymorphism means that you can put any derived class into a variable declared for the base class, and it’s a very fundamental concept of object-oriented programming.

    I first truly appreciated polymorphism when I started writing simple games.

    for instance:

    foreach(Enemy enemy in Enemies)
    {
        enemy.update();
    }
    

    each of those update calls can do something different, one can cause the enemy to shoot at you, where another can cause the enemy to change it’s position, but they all have an update call, and all the update calls have the same signature.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Try to describe polymorphism as easy as you can How would you
Possible Duplicate: Try to describe polymorphism as easy as you can What is polymorphism?
Possible Duplicate: Try to describe polymorphism as easy as you can I've never been
Possible Duplicate: How to catch exceptions I have not really had to use try
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: If Javascript has first-class functions, why doesn’t this work? When I try
Possible Duplicate: When to use try/catch blocks? Main method code entirely inside try/catch: Is
Possible Duplicate: Javascript Try-Catch Performance Vs. Error Checking Code A colleague of mine told
Possible Duplicate: NullPointerException when try to capture imagem from webcam I saw this good

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.