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

  • Home
  • SEARCH
  • 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 7521481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:14:30+00:00 2026-05-30T02:14:30+00:00

From some brief fiddling about, I find I get an error when overriding superclass

  • 0

From some brief fiddling about, I find I get an error when overriding superclass methods in a subclass when I do the following:

  • Override a protected superclass method with a private subclass method
  • Override a public superclass method with a protected or private subclass method

However, If I do it in the other direction, no error is thrown:

  • Overriding a private superclass method with a protected or public subclass method
  • Overriding a protected superclass method with a public subclass method

This seems counter intuitive to me – I was expecting it to work the other way around in order to enforce information hiding and encapsulation. This appears to allow poor design by allowing internals to be exposed in a way that may break other methods and I can’t see a case when this would be a good idea. Why has it been implemented this way and what have I missed?

Also, is this standard practice in other programming languages?

  • 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-30T02:14:31+00:00Added an answer on May 30, 2026 at 2:14 am

    What you call “enforce information hiding” is something, that may break subclasses, because suddenly properties and methods may disappear. You cannot break things by loosing restrictions this way.

    With private is a bit different: In this case the property/method does not exists from the child class’ point of view. Thus there is no reason, why a subclass may not introduce a property with that name, because it will be a different property.

    You are right, that this may lead to poor design, but you can always build an application with poor design.

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

Sidebar

Related Questions

From some old c++ code im trying to use a com dll, it works
I have coordinates from some source and want to tag my jpg files with
I believe (from some research reading) that counting down in for-loops is actually more
I read from some books that Phusion Passenger is the answer to easy Ruby
I have code examples from some of my previous work that help me to
I have read from some article that say's Apple doesn't approve the application which
I want to auto gen some DTOs from some of my existing objects, I
I have to read data from some files and insert the data into different
I'm building a python application from some source code I've found Here I've managed
First some brief background: I have an existing ASP.NET MVC 1 application using Entity

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.