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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:15:20+00:00 2026-06-15T20:15:20+00:00

When inheriting from a base class in a scenario when not all methods will

  • 0

When inheriting from a base class in a scenario when not all methods will be implemented, is it better to put empty methods in the base class so that sub-classes that don’t require that method can ignore it totally, while other classes must override the method if they want to implement it… e.g:

Base class:

public void myMethod() {
}

Sub-class that doesn’t implement:

<nothing!>

Or is it better to leave the base class cleaner and just put an abstract method in and force the sub-class to flesh out a blank method if it doesn’t implement that method?

Base class:

public abstract void myMethod();

Sub-class that doesn’t implement:

public void myMethod() {
}
  • 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-15T20:15:22+00:00Added an answer on June 15, 2026 at 8:15 pm

    It’s up to you and it really depends on the situation.

    You can use abstract methods when you have an abstract class and you want classes which extend it to implement that method (because the abstract parent class uses the abstract method – it may be something like print()). It’s similar to interface’s methods but it’s usually used in different scenarios. But I would use interface in most cases…

    I would use abstract method only in case that myMethod() does a different thing in each class that extends the abstract parent… Otherwise, if myMethod() does usually the same thing and one or two classes need to override it, I will use the first solution.

    Also look at the template method pattern. I don’t know which case is yours so I can’t answer this question in an exact way…

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

Sidebar

Related Questions

I have all my views in a project inheriting from a ViewBase class that
Consider this - a base class A, class B inheriting from A, class C
Say we have a class inheriting from two base classes (multiple inheritance). Base class
So I have a base class Animal which has 2 classes inheriting from it,
I have an abstract base class (Comparable) with Date and Time virtually inheriting from
I have a the following selenium test suite inheriting from the same base class,
I have a custom C# PowerShell Cmdlet (inheriting from the Cmdlet base class) and
I have a base class that initializes itself from a nib file. How can
I have a Base class with a method that a child class will almost
Given a list of classes inheriting from this base: class Plugin(object): run_after_plugins = ()

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.