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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:09:52+00:00 2026-06-14T10:09:52+00:00

Let’s assume the following scenario in Java public interface Foo { Object bar(); }

  • 0

Let’s assume the following scenario in Java

public interface Foo {
    Object bar();
}

public class Baz implements Foo {
    public Object bar() {
        //My implementation
    }
}

Why can I not make Baz.bar() static?

Doing so results in the compiler error This static method cannot hide the instance method from Foo Adding an @Override annotation to Baz.bar() changes the compiler error to The method bar() of type Baz must override or implement a supertype method

It seems to me that from the perspective of anyone using the interface Foo, the implementing class Baz would still fulfill the interface requirements, while making a method that has a static implementation available to anyone who is explicitly using the Baz class without instantiation.

How come the compiler doesn’t allow this scenario?

Edit:

Maybe I wasn’t clear enough, but what I’m actually asking is why this isn’t allowed, since from my point of view, I’m not decreasing the visibility of the interface-defined method.

And yes, I know I used the word abstract in the title, and not in the question, but that’s because the abstract keyword is implied in an interface.

Edit 2:

I’ll add an example that is closer to reality for clarity on why I am even asking this:

public interface DatabaseMapper<T extends DatabaseType> {
    Entry<T> convert(Entry);
}

public interface SQL extends DatabaseType {}

public class SQLEntry implements Entry<SQL> {}

public class SQLMapper implements DatabaseMapper<SQL> {
    public SQLEntry convert(Entry e) {
        //Convert some generic entry to the SQLEntry type
    }
}

In this case, I want to force all Mapper implementations to implement the convert method, but at the same time, this method might not depend in any way on the internal state of an SQLMapper object, and it might be desirable to be able to convert a generic Entry into a SQLEntry without going through an instantiation-process that probably includes database connection strings and the like.

This was the scenario I was faced with, and why I wanted to see if anyone knew why this was not possible to accomplish with the same method – e.g. not having to resort to a public static SQLEntry convertStatic(Entry e) which the overridden method delegates its implementation to.

Again though, I understand that this is not possible in Java due to how the compiler works – I am simply trying to understand why that is.

  • 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-14T10:09:53+00:00Added an answer on June 14, 2026 at 10:09 am

    The real answer is that Java simply wasn’t defined this way. In other language, this is possible.

    For instance, in Scala there aren’t static methods, but you can instead define static object that are singleton and that allow this. In dynamic language like Smalltalk or Ruby, classes are like objects, and this is also possible.

    But in Java, static methods are similar to global methods. There is not concept of self, nor super in a static method because it’s not bound to an object. By consequence inheritance/overriding doesn’t really apply.

    It unfolds that if there is no notion of inheritance, it also doesn’t make sense to speak of abstract.

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

Sidebar

Related Questions

Let's say I have the following classes : public class MyProductCode { private String
Let's say I have the following structure: abstract class Hand {} class Rock extends
Let's say I have the following object: var VariableName = { firstProperty: 1, secondProperty:
Let's say I have a domain object with the following field: private Map<StatType, Double>
Let's say you have a class called Customer, which contains the following fields: UserName
Let's say I have a method in java, which looks up a user in
Let me explain best with an example. Say you have node class that can
Let's say I have a custom class CustomClass, and I have a collection deriving
Let's say I have the following data frame: > myvec name order_no 1 Amy
Let's assume that a user votes for some movies in a scale of 1

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.