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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:30:52+00:00 2026-05-13T05:30:52+00:00

Hi I have a class A with as abstract method protected abstract List<Contributor> GetContributors(List<SyndicationPerson>

  • 0

Hi I have a class “A” with as abstract method

protected abstract List<Contributor> GetContributors(List<SyndicationPerson> contributersList);

I want to override this method in derived class “B” with following conditions

  • It should be private to B class.

compiler does not allow me to declare this Method as private in derived class “B”
what is the correct syntax ?

  • 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-13T05:30:52+00:00Added an answer on May 13, 2026 at 5:30 am

    You can’t. That would violate the accessibility level declared in class A. Aside from anything else, it would stop it from being callable by class A! What would you expect to happen if code in class A tries to call the abstract method which you’d somehow overridden with a private implementation?

    You can make the main implementation private and then create a protected method which just calls the private one, if you really want to.

    Why do you want to make the method private in the first place, when it’s designed to be callable from A?

    EDIT: Okay, now you’ve explained in your comment what you want to do, you can’t do it. The closest you can come is to pass a delegate to A’s constructor – that delegate can refer to a private method. Unfortunately, you can’t use “this” when you pass arguments in constructor chains, so you’re forced to do something horrible such as writing a static method which takes “this” as its first parameter, effectively… except that it will have to cast it to the right type as well, as the parent can’t declare which type it should be. The parent would then call the delegate instead of the protected method.

    Note that this would also prevent further derived classes from “overriding” further, which may or may not be desirable.

    It’s incredibly tortuous, and I’d try to avoid it wherever possible. If you’re really worried about what derived classes might do, I’d try to seal the class instead and force people to use composition instead of inheritance. The language doesn’t really help you do what you want to here.

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

Sidebar

Related Questions

I have the following class: public abstract class AbstractParent { static String method() {
I have an abstract class defining a pure virtual method in c++: class Base
I have a class with some abstract methods, but I want to be able
Can an abstract class have a constructor? If so, how can it be used
I have an abstract class: type TInterfaceMethod = class abstract public destructor Destroy; virtual;
I have a class which is not thread safe: class Foo { /* Abstract
I have an abstract Class Monitor.java which is subclassed by a Class EmailMonitor.java .
I have an abstract class and I would like to use it quickly by
If I have a base class such that public abstract class XMLSubscription <T extends
In my domain model I have an abstract class CommunicationChannelSpecification, which has child classes

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.