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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:10:51+00:00 2026-05-27T20:10:51+00:00

Since static fields objects are created at class level(and common to all objects), Is

  • 0

Since static fields objects are created at class level(and common to all objects), Is it static import on particular fields and inheriting(using implements) all the fields will create same amount of memory?

For Example In this below propgram how many MyOwn objects are created?

class MyOwn{}

public interface ConstantIfc {
  public final static MyOwn REF = new MyOwn();
}

class A implements ConstantIfc {}
class B implements ConstantIfc {}

public class c {
   public static void main(String... arg) {
      A refA = new A();
      B refB = new B();
   }
 }

If it is same how final constant class for static import is better than constant interface?

Update:

I understood that It is better to avoid Inherittance for constants. Improperly leveraging implementation inheritance often leads to inflexible design. So we can better go for static import of class/interface. but still Interfaces are an abstraction, and to remain abstract, they should not contain implementation details (including constant variables.) Interfaces also are often used to describe a public API, in which implementation details do not belong. For this reason it makes sense to put constant data into a class, rather than an interface. Thanks robjb.

  • 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-27T20:10:52+00:00Added an answer on May 27, 2026 at 8:10 pm

    In the example you give there’s only one MyOwn object that gets created. It is created the first time your program loads the ConstantIfc interface.

    Even if you used static imports the answer will still be the same. static imports are not supposed to be performance-wise better than constants-in-interfaces. They were introduced into the language for the purpose of avoiding interfaces which all they do is define constants as never used as interfaces (no variable is typed with the them) and thus induce confusion.

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

Sidebar

Related Questions

I am using a separate class with only static fields, to store current application
I got a Utility module since VB.NET doesn't have static class like C# and
When I call a static method like: Something.action(); Since a instance isn't created how
I'm trying to build a C/C++ static library using visual studio 2005. Since the
Since both a Table Scan and a Clustered Index Scan essentially scan all records
Since the WMI class Win32_OperatingSystem only includes OSArchitecture in Windows Vista, I quickly wrote
Is it possible to get the class type from inside the static initialization block?
I'm maintaining an API that has deprecated some public static fields. CheckStyle complains loudly
I have a coworker who writes unit tests for objects which fill their fields
I'm using VS2010 and created a simple asp. web forms application, using Development Server

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.