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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:01:40+00:00 2026-06-09T10:01:40+00:00

Here’s one I’ve been scratching my head over for a while now. Suppose you

  • 0

Here’s one I’ve been scratching my head over for a while now.

Suppose you want to specify a method in an interface, but you don’t want it actually defined until the implementation level. That is to say, you want to specify a method in an interface such that if it is defined in an abstract class the compiler will throw an error.

public interface Thing{   

    public void method1();

    public void method2();

    //method3 should be implementation specific
    public void method3();

}

And then I have an abstract class:

public abstract class BasicThing{

    @Override
    public void method1(){}

    @Override
    public void method2(){}

}

And my implementation specific code:

public class ThingImpl{

    @Override
    public void method3(){}

}

(By the way, I know that it’s an valid to just write it this way, but my reason in wanting to do this is so that if I’m writing the interface and passing it along to someone else who then passes it along to do the final implementation, I want to be able to force the extra specification on them)

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

    No, there’s no way of doing this at compile-time. It’s a pretty odd requirement too, IMO.

    You can do it the co-operation of the abstract class of course, as Sheik’s answer shows. But you can’t force an abstract class to do that by virtue of putting something specific in the interface.

    You could potentially try to find all the relevant classes and validate your requirements in a unit test.

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

Sidebar

Related Questions

Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
I have a jquery bug and I've been looking for hours now, I can't
Here's what I'm trying to accomplish with this program: a recursive method that checks
here is my php code $titikPetaInti = array(); while($row = mysql_fetch_assoc($hasil2)) { $titikPetaInti[] =
Here's what I'm doing. I want to upload multipart file via Ajax to my
Here is my code...I have two dimensional matrices A,B. I want to develop the
here i want to understand the architecture of bluez (Bluetooth Stack Protocol). I understood
Here is an object that I'd like to use with ng-repeat, but it's not
Here is my code <!doctype html> <html> <head> <meta charset=utf-8> <script src=js/jquery-1.7.2.min.js></script> <style> div{
Here's my code: StreamReader reader = new StreamReader(war.txt); string input = null; while ((input

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.