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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:18:01+00:00 2026-05-28T06:18:01+00:00

so i was trying to understand the interfaces , but i almost only see

  • 0

so i was trying to understand the interfaces, but i almost only see articles that explains “how” to use the interface, my problem is to understand the “why” :
so it’s better to use Interface than creating and subclassing a class, which might be useless,
so we implement the interface methods in the class, but i don’t understand why this is a good thing,

Let’s say :
a class like Car.java defines all the code to make the car
we create the interface Working.java with several methods like start(), stop(), etc.
we implement the methods in Diesel_Car.java, Electric_Car.java, etc.
so what does it change for Car.java? This might not be the best example, as it seems that Car should be the parent of Diesel_Car.java etc,
but what was the meaning to implement the methods in those classes?
Is there a method in Car.java that somehow “calls” the Diesel_Car.java class and its interface methods?

I’ve read that the interface is like a “Contract”, but i only see the second part of this contract (where the method is implemented) and i’m having some trouble to imagine where the first part happen?

Thanks for your help

  • 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-05-28T06:18:02+00:00Added an answer on May 28, 2026 at 6:18 am

    Lets take your example of a Base class of Car with Electric_Car and Diesel_Car Subclasses, and expand the model a bit.

    Car may have the following Interfaces

    1. Working : with start() & stop() methods
    2. Moving : with move(), turn() & stop() methods

    The Car might contain an instance of class AirConditioner which should also implement the interface Working.

    The Driver object can interact with objects than implement Working , the driver can start() or stop() . (The driver can start or stop the car and the A/C seperatly).

    also, since the Driver can walk around on his own (and does not always need a car) he should implement the interface Moving.
    The object Ground can now interact with anything that implements Moving : either car or driver.

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

Sidebar

Related Questions

I m trying to understand Interfaces so that I can implement them in my
I'm trying to see if I understand depedency injection. I have a project that
Trying to understand the use of verifySet etc... but unless I do a workaround
Trying to understand the options for will_paginate's paginate method: :page — REQUIRED, but defaults
Trying to understand Ruby a bit better, I ran into this code surfing the
Just trying to understand that - I have never used it before. How is
I've been trying to understand how Ruby blocks work, and to do that I've
I am trying to understand a C++ code that reads a dll explicitly. Does
I'm trying to understand something that , by googling around, seems like a bug
I'm trying to understand this but I didn't get any appropriate results from searching.

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.