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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:00:19+00:00 2026-05-22T20:00:19+00:00

In Java, if I have an interface: public interface MyInterface{ } Then MyInterface implementation

  • 0

In Java, if I have an interface:

public interface MyInterface{
}

Then MyInterface implementation is:

class MyClass implements MyInterface {
    public MyClass(int a) {
    }
}

So what I mean is that if a user wants to do declare a MyInterface instance with constructor:

MyInterface mine = new MyInterface(2);

then it is not possible right?

  • 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-22T20:00:19+00:00Added an answer on May 22, 2026 at 8:00 pm
    MyInterface mine = new MyInterface(2);
    

    then it is not possible right?

    That’s right. You can never do something like

    MyInterface mine = new MyInterface(2);
    

    After new you have to pick a class that implements the interface(*), such as MyClass:

    MyInterface mine = new MyClass(2);
    

    Why?
    You can think of an interface as a property of a class. An analogy would be an adjective, such as “Red”. It makes perfect sense to create, say, a red ball (new RedBall()) or a red car (new RedCar()), but just creating “red” (new Red()) doesn’t make sense (“red what??”).

    (*) You can create anonymous classes that implement the interface on the fly by doing new MyInterface() { ... } but technically speaking you’re still instantiating a class.

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

Sidebar

Related Questions

Suppose I have a class that implements an interface: public class A implements IB
Let's say I have the following Java interface that I may not modify: public
I have a Java interface in an API that contains a single method: public
I have a Java project that needs a addon interface. I was thinking about
An enum in Java implements the Comparable interface. It would have been nice to
I have a problem in Java: I have an interface: public interface I extends
I have an interface like the following: package example; import java.awt.Point; public interface Thing
I have an interface @PersistenceCapable public interface MyInterface { public abstract String getName(); public
I have code that looks like follows: public interface BaseDAO{ // marker interface }
I have a DBAdmin class that connects to the database, and then some other

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.