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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:57:20+00:00 2026-06-10T21:57:20+00:00

I have a rather basic question about interfaces, something I’m rather new too. I

  • 0

I have a rather basic question about interfaces, something I’m rather new too. I typically would instantiate my class with an overloaded constructor. I’m now trying to use interfaces and wondering how I would populate my constructor. Would I just use something like setSomeMethod(arguement1, arguement2) in my interface to populate my attributes?

I’d also like to note I’m using “Tapestry5” framework with service Injection. Example

public class Main {

    @Inject
    private Bicycle bicycle;

    public Main() {
         //Not sure how to pass constructor variables in
         this.bicycle();
    }

}

Interface

public interface bicycle {
   public void someMethod(String arg1, String arg2);
}

Impl Class

public class MountainBike implements bicycle {

   private String arg1;

   private String arg2;

   public MountainBike() {
       //Assuming there is no way to overload this constructor
   }

   public void someMethod(String arg1, String2 arg2) {
       this.arg1 = arg1;
       this.arg2 = arg2;
   }

} 

Then how do you handle extended classes? I’m not sure how to populate the extended class constructor.

public class MountainBike extends BicycleParts implements bicycle {

   private String arg1;

   private String arg2;

   public MountainBike() {
       //Assuming there is no way to overload this constructor
       //Not sure where to put super either, but clearly won't work here. 
       //super(arg1);            
   }

   public void someMethod(String arg1, String2 arg2) {
       this.arg1 = arg1;
       this.arg2 = arg2;
       //Assuming it doesn't work outside of a constructor, so shouldn't work 
       //here either.   
       //super(arg1);
   }

} 

public class BicycleParts {

    private String arg1;

    public void BicycleParts(String arg1) {
        this.arg1 = arg1;
    }

}

Thanks in advance.

  • 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-10T21:57:21+00:00Added an answer on June 10, 2026 at 9:57 pm

    First off, your bicycle method should be declared with a return type:

    public void someMethod(String arg1, String arg2);
    

    Interfaces define a contract for methods and not how objects are instantiated. They can also define static variables.

    To use someMethod in your MountainBike constructor, you could make the call in the constructor:

    public MountainBike(String arg1, String arg2) {
       someMethod(arg1, arg2);
    }
    

    Wrt, your question on extending the class, the super statement must appear as the very first statement in the constructor i.e.:

    public class MegaMountainBike extends BicycleParts implements bicycle {
    
       public MegaMountainBike() {
    
          super("Comfy Saddle");
          // do other stuff
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm relatively new to SVN and have a rather basic question. I have several
I have a rather basic and general question about atomicity of UPDATE ... SET
I'm rather new to OOP and have a question about how to best deal
I have a simple basic question about C# and inheritance. In the below example,
I have a basic Layout question. When using the layout tab (rather than the
Hi all rather a basic question but it appears I have to do a
So I have a rather basic javascript problem which I have been slamming my
What I'm trying to do is rather basic, but I might have my facts
Have a rather simple question. Does anyone knows if i can use jparallax both
I have a rather large text corpus, of which I would like to check

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.