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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:01:22+00:00 2026-05-24T14:01:22+00:00

Clarification: this question is not about access modifier Confirmed that B.m() and b.m() statements

  • 0

Clarification: this question is not about access modifier

Confirmed that B.m() and b.m() statements both works in the following code:

class A {
  static void m() { //some code }
}

class B extends A {
}

class Example {
  public static void main (String [] args) {
    B.m(); // running A's m() static method
  }

  public void try() {
    B b = new B();
    b.m(); // running A's m() static method
  }
}

My question is can we said “static method is inherited”?

if “inherited” is the correct term, if we add a method to B class we same signature of the static class:

class A {
  static void m() { //some code }
}

class B extends A {
  static void m() { //some code }
}

class Example {
  public static void main (String [] args) {
    B.m(); // running B's m() static method
  }

  public void try() {
    B b = new B();
    b.m(); // running B's m() static method

    A a = new B();
    a.m(); // running A's m() static method, no polymorphism
  }
}

In this case, notice that we have no polymorphism, is it the correct term to said that “static method is inherited but not overridden, subclass static method hide superclass static method”?

Last doubt, for these 2 terms, “inherited” and “overriden”, which one is directly tied to the term “polymorphism” ?

  • 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-24T14:01:24+00:00Added an answer on May 24, 2026 at 2:01 pm

    Yes, I think “inherit” is the correct term here, even if it’s not as descriptive as it might be. From section 8.4.8 of the Java Language Specification:

    A class C inherits from its direct superclass and direct superinterfaces all non-private methods (whether abstract or not) of the superclass and superinterfaces that are public, protected or declared with default access in the same package as C and are neither overridden (§8.4.8.1) nor hidden (§8.4.8.2) by a declaration in the class.

    That doesn’t specify instance methods, but there are specific restrictions on what is allowed to hide or override what, which wouldn’t make sense if static methods were not inherited.

    Really though, I would simply view static methods as “accessible without qualification” rather than anything else, given that they don’t take part in polymorphism etc. I think it’s worth being very clear about that – for example, one static method can hide an inherited one, but it can’t override it.

    In other words, while I think “inherit” is technically correct, I would try to avoid using it without any further explanation.

    For your second question, I’d say that based on the above, overriding is tied to polymorphism, but inheriting isn’t necessarily.

    (I would also strongly advise you to avoid calling static methods “via” variables, and also to use the name of the class which declares the static method wherever you specify the name at all. I know that’s not part of the question, but I thought I’d just add it anyway…)

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

Sidebar

Related Questions

Clarification: this is not about user agent calls to pages, but Classic ASP calling
I have a byte array that represents a complete TCP/IP packet. For clarification, the
I'm in need of some clarification. I've been reading about REST, and building RESTful
This might sound stupid, but why doesn't the Java compiler warn about the expression
Clarification : Thanks for the suggestions of tools for validating XHTML. I'm primarily looking
(If anything here needs clarification/ more detail please let me know.) I have an
Is global memory initialized in C++? And if so, how? (Second) clarification: When a
As the author of a C# application, I found that troubleshooting issues reported by
Lots of BAWs (big ass-websites) are using data storage and retrieval techniques that rely
(I'm using the pyprocessing module in this example, but replacing processing with multiprocessing should

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.