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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:22:59+00:00 2026-06-03T06:22:59+00:00

I having a class named Shape which has two subclasses Shape1 and Shape2. In

  • 0

I having a class named Shape which has two subclasses Shape1 and Shape2. In the Shape class I have variables Xpos and Xpos and methods namely:

public int getXpos(){
    return Xpos;
}

public void setXpos(int x){
    this.x = x;
}

// Same thing for y

Now let’s just say in the class Shape, x = 10. Now when I inherit it:

public class Shape1{
    Shape1(){
        xPos = 100;
        // ...
    }
}

and:

public class Shape2{
    Shape2(){
        xPos = 200;
        // ...
    }
}

But when I do Shape1.getX() in another program, I get 10 as a result. Can someone tell me why I’m not getting 100? Is the problem with the ‘this’ keyword?

  • 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-03T06:23:01+00:00Added an answer on June 3, 2026 at 6:23 am

    xPos cannot be static. If it is static the same number will appear twice. (the original shape)

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

Sidebar

Related Questions

I'm currently having a Class named SqlData, which contains all the Methods needed to
I am having a Server Class which has delegate methods of NSURLConnection. And I
I have a super-class named ClassA and two sub-classes Class1 and Class2. I have
I am having a inner class(static) named SelectProdLineAssociationForm I have also given a declaration
I have a form in spring mvc 2 having command class Class1 I want
I have a div having a css class MyClass. Inside this div, I can
I have a class named PageBase inheriting from ASP.NET Page . I want to
I have a miniblog application, with a class named New (referring to a new
I have a page on which I'm using JQuery Mobile. I am having difficulty
I have a custom class named BlinkingLight. I also have a static ObservableCollection BlinkingLightCollection.

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.