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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:18:33+00:00 2026-05-24T03:18:33+00:00

Simple question. I made a class called Tester1 which extends another called Tester2. Tester2

  • 0

Simple question. I made a class called Tester1 which extends another called Tester2. Tester2 contains a public string called ‘ABC’.

Here is Tester1:

public class Tester1 extends Tester2
{
    public Tester1()
    {
         ABC = "Hello";
    }
}

If I instead change line 5 to

super.ABC = "Hello"; 

am I still doing the exact same thing?

  • 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-24T03:18:35+00:00Added an answer on May 24, 2026 at 3:18 am

    Yes. There’s only one ABC variable within your object. But please don’t make fields public in the first place. Fields should pretty much always be private.

    If you declared a variable ABC within Tester1 as well, then there’d be a difference – the field in Tester1 would hide the field in Tester2, but using super you’d still be referring to the field within Tester2. But don’t do that, either – hiding variables is a really quick way to make code unmaintainable.

    Sample code:

    // Please don't write code like this. It's horrible.
    class Super {
       public int x;
    }
    
    class Sub extends Super {
        public int x;
    
        public Sub() {
            x = 10;
            super.x = 5;
        }
    
    }
    
    public class Test {
        public static void main(String[] args) {
            Sub sub = new Sub();
            Super sup = sub;
            System.out.println(sub.x); // Prints 10
            System.out.println(sup.x); // Prints 5
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just a simple question: I have read that a class should be made static
I have a simple method which is called from multiple threads; @Override public Bitmap
Very simple question, I made the following program : #include <stdlib.h> int main(int argc,
I'm new to entity frame work code first. I have simple class called Cat
I hope this is a simple question. Can I inherit both an abstract class
My situation is essentially this: I have a class called Foo which has dependencies
I have a simple question. I have a model that looks like this: public
My question is rather simple, given: class MyClass{ function a(){ echo F.A ; }
I have, what I think/hope, is a very simple PHP question. I have made
Simple question, but one that I've been curious about...is there a functional difference between

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.