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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:00:07+00:00 2026-06-06T09:00:07+00:00

If class a extends class b , and class b extends class c ,

  • 0

If class a extends class b, and class b extends class c, does a inherit from both c and b? If so, in case of conflict between the 2, is there an error or does one override another (and if so, which one)?

Please rename the question if it is unsuitably titled.

EDIT: what I mean by conflict is something like the following:

class c {
   int foo;
   //Stuff
}
class b extends c {
   String foo;
   //Stuff
}
class a extends b {
   //Stuff
}

Is a.foo a string or an int?

Another edit: So from what I gather, inheritance here is a bit like CSS – the closer the rule is set, the larger priority it has (e.g. inline styles override stylesheets). Is that a good way of considering this, or is it significantly different?

  • 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-06T09:00:14+00:00Added an answer on June 6, 2026 at 9:00 am

    Yes, a inherits from b and c. I don’t see how there can be a conflict in this situation since b’s method overrides will be valid for a. You may be thinking of the diamond problem that comes from conflicts from multiple inheritance, but that’s when you have two different parents, not two parents with one parent being the parent of the other.

    You can run into a “soft” diamond problem with interfaces, where two methods have the same signature, but the rules for one method don’t match those of another. Since neither interface has an implementation for their methods, there is no compilation problem (that I know of), just a logical problem.

    Edit Ah, I’ve seen your edit regarding variables, and I agree with Jimpanzee’s response to it. It’s certainly easy to test:

    public class Test3 {
       public static void main(String[] args) {
          MyA myA = new MyA();
          System.out.println("foo := " + myA.foo);
       }
    }
    
    class MyC {
       public int foo = 3;
       //Stuff
    }
    class MyB extends MyC {
       public String foo = "foo";
       //Stuff
    }
    
    class MyA extends MyB {
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have set of classes which inherit from a single super class: Super |
I need to create a base class that extends Activity which does some common
Let's say I have a class 'Person' and another class 'Survey' which extends person
Does something like this make any sense at all in Java? class A<T extends
I have a CustomButton class (extends LinearLayout ) where I inflate a layout which
I am making an app in which my class extends RelativeLayout and implements OnClickListener
I am writing a Scala class to inherit from a Java class, and I
I have the following situation. I have a Java Class that inherits from another
Can a class inherit from Entity Framework class and still persist back to the
If you have a class named User and another class named Admin that extends

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.