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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:05:58+00:00 2026-06-09T01:05:58+00:00

Superclass -> Vehicle | Subclasses -> Car & Bike If the class Car requires

  • 0

Superclass -> Vehicle |
Subclasses -> Car & Bike

If the class Car requires a startCar() method (which outputs
a string of value ‘BRUMM’ when invoked) and even the class
Bike requires a similar method startBike() (which outputs
a string of value ‘TRUMM’ when invoked) Would it be better
to go about it this way, or instead have a startVehicle()
method in the superclass Vehicle which is coded differently for
the different outputs for the respective subclasses: Car and Bike?

Edit: Bike refers to Motor Bike

  • 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-09T01:05:59+00:00Added an answer on June 9, 2026 at 1:05 am

    First, instead of using startCar() and startBike() [and startVehicle()] respectively, the function could [and should] just be called ‘start()’ (e.g. Car.start(), Bike.start(), Vehicle.start()), as each function shares the same intention, and is designed to give the same type of output.

    Now, if most/all of your subclasses are going to implement a start function then I’d recommend creating the start() function in the superclass, and then overriding it in the subclasses.

    Additionally, if Car.start() and Bike.start() share a lot (but not all) of the same functionality (e.g. they both start an engine of some sort), then put the similar code into the Vehicle.start(). Then, when you write Car.start() and Bike.start() to override Vehicle.start(), the respective functions should call Vehicle.start() method, before running their class-specific code.

    P.S. Definitely do not code the superclass’s start() function to put out a different value based on a class’s actual type; basically a superclass shouldn’t have to know about the subclass… otherwise, what’s the point? 🙂

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

Sidebar

Related Questions

I have a superclass Person, which contains the following method: public String getClasHierarchy() {
I have the super class Vehicle , with it's subclasses Plane and Car .
I have a superclass we can call class A and few subclasses, e.g. class
I get a NullPointerException calling a Superclass Method in Subclass Inner Class Constructor... What's
Assuming I have the superclass A, and the subclasses A1 and A2 which inherit
I have a superclass of type Question which has multiple subclasses (e.g. MultipleChoiceQuestion and
I have superclass (Class A) with a number of subclasses (Class B, Class C,
I have a class, which has a bunch of subclasses that inherit from it.
I have a superclass which implements the Comparable Interface and overrides the compareTo() method.
I have an abstract superclass and various subclasses. Each subclass contains a value that

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.