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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:07:06+00:00 2026-05-26T19:07:06+00:00

I have 2 questions, but they are about the same (similar?) problem. First question:

  • 0

I have 2 questions, but they are about the same (similar?) problem.

First question:

public class A {

    public void myProcedure() {
        doSomethingA();
    }

    private void doSomethingA() {}

}

public class B extends A {

    @Override
    public void myProcedure() {
        doSomethingB();
        // IT DOESN'T CALL super.myProcedure
    }

    private void doSomethingB() {}

}

public class C extends B {

    @Override
    public void myProcedure() {
        // I need to execute A's myProcedure here
    }

}

How to run A‘s myProcedure, without setting doSomethingA to public?

Second question:

I create my own TextBox, there is a variable named myValue. Now I create an AdvancedTextBox that inherits TextBox, and AdvancedTextBox need to access myValue variable. The problem is, I want future developer using both TextBox and AdvancedTextBox, or inherit them can’t access myValue. Is it possible?

EDIT: Oli Charlesworth and NullUserException ఠ_ఠ tell me to let C inherit A directly (first question). However, there’s some cases this can be disaster. For example: A = TextBox, B = AdvancedTextBox, C = NumberAdvancedTextBox, if C inherits A, so C have to do everything that B does again, with some small changes.

  • 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-26T19:07:07+00:00Added an answer on May 26, 2026 at 7:07 pm

    How about this …

    • Put A and C in the same package, and then put B in a different package.
    • Remove “private” from A.doSomethingA()
    • Give C an instance of A. ( Favor Composition Over Inheritance )
    • Since C and A are in the same package, C can call A.doSomethingA() anytime.

    Here is definition of A

    package ac; 
    
    public class A {
    
        public void myProcedure() {
            doSomethingA();
        }
    
       void doSomethingA() {}
    
    }
    

    Here is definition of B

    package b;
    
    public class B extends A {
    
        @Override
        public void myProcedure() {
            doSomethingB();
            // IT DOESN'T CALL super.myProcedure
        }
    
        private void doSomethingB() {}
    
    }
    

    Here is definition of C

    package ac;
    // do you really need to extend B? 
    public class C {
        A a = new A();
    
        public void myProcedure() {
            a.doSomethingA(); 
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read similar questions but they talk of AI models. What I want
I know there have been some similar questions to this, but they haven't helped
I have been pouring over many forums and questions similar (but not the same)
I have read several questions regarding this but I fear they may be out
guys I have two question to ask, they're easy, but bothering me for a
I've tried to put together a solution from similar questions but have failed miserably.
There might be similar questions but I still have some parts that I couldn't
similar questions have been asked before but I cant find an exact match to
Similar questions have been asked but cannot find a solution that works well. What
I am aware that questions about recurring events are common but I have not

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.