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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:13:21+00:00 2026-06-14T13:13:21+00:00

is re-defining a non-static method in a subclass with the same everything but as

  • 0

is re-defining a non-static method in a subclass with the same everything but as static overriding or hiding it ?

http://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html says hiding. but when i declare the superclass method as final, i get an override error.

superclass declaration is

final static void display() { ... }

subclass:

void display() { ... }

gives override error.

  • 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-14T13:13:22+00:00Added an answer on June 14, 2026 at 1:13 pm

    Is re-defining a non-static method in a subclass with the same everything but as static overriding or hiding it?

    It’s neither, because doing so triggers a compilation error, rendering your program invalid.

    class A {
        void x();
    }
    class B extends A {
        // ERROR!!!
        static void x();
    }
    

    Hiding happens when both methods in the pair are static methods; overriding happens when both methods in the pair are instance methods. When one of the two is a static method and the other one is an instance method, Java considers it an error. It does not matter if the instance method is final or not; it also does not matter if the static method is in the base or in the derived class: Java calls it an error either way.

    The compiler message that says “cannot override” is misleading, though: I think that “name collision” would have been a better name for such conditions, because “overriding” is reserved for situations with two instance methods.

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

Sidebar

Related Questions

i need to call a non-static method from an async operation , for ease
Defining custom components in Facelets is easy and quick but there's one thing I
I recently found out that the types of parameters in a non-defining function declaration
I have this sample code where I'm defining an array but it doesn't compile:
Techies-- I think I'm defining this static extension correctly for Split, I obviously am
when i use non-ascii character for defining global array, for example: const char table[]
What is the best way to have a static member in a non-templated library
I have declared some Non-Content data in an Orchard CMS by defining the records
Does a class have to allocate memory for its non-static member functions every time
What are the things that you would consider when defining indexes, clustered and non-clustered,

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.