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 7846591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:37:58+00:00 2026-06-02T17:37:58+00:00

I had an interview question that asked how I would design a system to

  • 0

I had an interview question that asked how I would design a system to show cars/trucks/vans at a kiosk so customers could look at specs on the vehicles. (Warning: I have not done much OO programming lately so bad vocabulary may follow)

I said I was start with a class, vehicle that had very basic properties like wheelbase, drive train, hp. Then I would subclass that into car, truck or van where I could have more specfic measurements like bed length for trucks or trunk capacity for cars.

Then they asked, how would I add options. I said that options could probably exist on any vehicle so I would say that a vehicle could have a list of options.

Finally they asked, what if there was an option that was only available on trucks and vans but not cars and I was a little stumped. Is there some way to make this nicely happen given the layout I described? Is there a better way to set up the class hierarchy to solve this? Or is this just a more complex problem that cant easily be solved without adding some extra logic?

  • 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-02T17:38:00+00:00Added an answer on June 2, 2026 at 5:38 pm

    There are a few options for that scenario.

    First, the easy one:

    Option #1 – Interface for Trucks/Vans

    If only trucks and vans implement Options, then create an interface called IVehicleOptions and have trucks and vans implement it:

    public interface VehicleOptions
    {
      Options { get; }
    }
    

    The drawback to this is that now you have to treat cars differently than trucks and vans.

    Option #2 – Null Design Pattern

    However, you can use the Null Design Pattern. Have Car implement IVehicleOptions, and just return null:

    public class Car : IVehicleOptions
    {
      public VehicleOptions { get { return null; } }
    }
    

    Option #3 – Strategy Pattern

    Create a base class, like Vehicle:

    public abstract class Vehicle
    {
      public Options Options { get; protected set; }
    }
    

    And have each concrete class set it:

    public class Car : Vehicle
    {
      public Car()
      {
        this.Options = NullOptions();  // This is the null design pattern used with this strategy pattern
      }
    }
    
    public class Truck : Vehicle
    {
      public Truck
      {
        this.Options = SuperOptions();
      }
    }
    
    public class Van: Vehicle
    {
      public Van
      {
        this.Options = ElegantOptions();
      }
    }
    

    Now all vehicles can be treated the same way (as a Vehicle).

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

Sidebar

Related Questions

I had an interview question that asked me for my 'feedback' on a piece
Recently i had an interview in which the question was asked as How would
I had an interview and a question that seems really simple was not clicking
I had telephone interview question yesterday. The interviewer asked me if I had faced
Yesterday i had a question in an interview which i thought i could find
I was asked the following question during phone interview I had: Given the following
I was asked this question in an interview and had no idea. And I
I had an interview today and the person asked me this question: How do
I had an interview today and was asked this question! code the MS Paint
Recently I had a question on the interview - I was asked to compare

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.