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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:26:55+00:00 2026-05-22T17:26:55+00:00

Hi I am facing a design problem which I think it should be quite

  • 0

Hi I am facing a design problem which I think it should be quite common:

public abstract class Parent
{
    ...

   public boolean itsOk()
   {
       return true;
   }
   public void execute()      
   { 
       if (itsOk()){
          System.out.println("done");
       }
   }
}

I need to be able to override itsOK() function in any subclass inherited from ‘Parent’ even if arguments are different.

public class Example extends Parent
{
    public boolean itsOK(int a)
    {
       if (a==1)      return true;
       else           return false;
    }

}

Then when I call execute, I want the subclass’ itsOk() method to be invoked.

public static void main(String[] args) {
    Example e=new Example();
    e.execute();
}

This works ok if the subclass’ itsOk() method has no arguments (like the ‘Parent’s method), so it’s an overriding case, but how can I make it when arguments are different?

  • 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-22T17:26:55+00:00Added an answer on May 22, 2026 at 5:26 pm

    In such a case I would rather try to have the same method signature in the parent and the child class, ie. a real overwriting and not an overloading. Then, your parameter a could be a member of the class Example which would avoid the need for a parameter. Of course it strongly depends on the rest of the code.

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

Sidebar

Related Questions

I'm facing a problem which is probably extremely common in game-design. Let's assume that
I'm making the design of a OO framework and I'm facing the following problem.
I am facing a little annoying design problem. Not easy to give a title
I want to design a Forum using Php but the problem I am facing
i'm facing a design problem within my project. PROBLEM i need to query solr
I’m currently facing a design problem and would appreciate advice on how I could
I am facing a problem of design time support best practices. I am using
I am often facing design patterns, and I find most articles explaining them a
i am doing a database design using EAV. I am facing an issue when
When facing the problem of validating a property in a JSF2 application there are

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.