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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:35:03+00:00 2026-06-05T02:35:03+00:00

When ‘SubClass’ extends ‘SuperClass’, when it inherit its methods and properties, it creates methods

  • 0

When ‘SubClass’ extends ‘SuperClass’, when it inherit its methods and properties, it creates methods and properties that distinguishes from the ‘SuperClass’?

Or if I create an instance of ‘SubClass’ and I try to modify a property, that was inherited from ‘SuperClass’, am I modificating the super class property also?

Thanks.

EDIT

package {

    public class SubClass extends SuperClass {

        public function SubClass() {
            trace('superclass value n='+superClass.n+'\n');
            trace('subclass changes inherited n'+'\n');
            n = 3;
            trace('subclass value n='+n+'\n');
            trace('superclass value n='+superClass.n+'\n');
        } 
    } 
} 

Returns me:

superclass value n=-1;
subclass changes inherited n;
subclass value n=3;
superclass value n=3;
  • 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-05T02:35:06+00:00Added an answer on June 5, 2026 at 2:35 am

    I will explain it in short.

    We have two classes – Subclass and SuperClass.

    SuperClass have four methods:

    • private function methodPrivate():void;
    • protected function methodProtected():void;
    • public function methodPublic():void;
    • internal function methodInternal():void;

    From the Subclass you:

    1. Cannot access methodPrivate():void;
    2. Can access methodProtected():void; but just like your private method, it means, you cannot access it from outside of Subclass.
    3. Can access methodPublic():void; and everything can access if from outside of Subclass also.
    4. methodInternal():void; is available for classes from the package of SuperClass.

    You can however override these methods. Overriding doesn’t change a methods of SuperClass but change them only in SubClass.

    override public function methodPublic() : void {
        // your additional code
        super.methodPublic(); // eventually calling the same method of SuperClass, you can pass arguments to it also
    }
    

    As you know, your SuperClass can also have variables, that also can be public, protected, private or internal. You cannot override them, but you can do this with getters or setters however.

    You can access variables that are created as public or protected by using a word “super” like this: super.someVariable .

    So everything is up to you, if you want to create a different variables of the same name in SuperClass and SubClass, just declare one as private in SuperClass. If you want to have one variable that SuperClass and SubClass both can access – just declare it as protected or public.

    Hope that was clear.

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

Sidebar

Related Questions

I downloaded PostgreSQL from the official website and ran the .dmg installer. After that
I am trying to create a RegEx expression that will successfully parse the following
I'm trying to create an if statement in PHP that prevents a single post
I've got a string that has curly quotes in it. I'd like to replace
I am doing a simple coin flipping experiment for class that involves flipping a
I have a text area in my form which accepts all possible characters from
Hi if i run my project its indicate this logcat error...how to solve this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from

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.