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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:45:06+00:00 2026-06-14T23:45:06+00:00

I am trying to understand Java interfaces like the millions of others around the

  • 0

I am trying to understand Java interfaces like the millions of others around the world. How do I test that I’m really using my interface? If I remove the “implements” in my TestBubbles class I still get the same results. I can change either method definition and get a compilation failure but how do I test the data I’m passing?

public interface Bubbles {
   public void addAir(String bubbleType, float bubbleOne, float bubbleTwo );
}

public class TestBubbles implements Bubbles {

    public static void main(String [] args){
      String type = "wiggly";
      float sizeOne = 42.01f;
      float sizeTwo = 80.10f;

      TestBubbles tb = new TestBubbles();
      tb.addAir(type, sizeOne, sizeTwo);

}


   public void addAir(String rType, float fOne, float fTwo ){
       System.out.println(rType + " " + fOne + " " + fTwo);

   }

}
  • 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-14T23:45:07+00:00Added an answer on June 14, 2026 at 11:45 pm

    You test that, and you should code that by defining your variables with the type of the interface instead the type of your class.
    Look at your line:

    TestBubbles tb = new TestBubbles();
    tb.addAir(type, sizeOne, sizeTwo);
    

    When programming to interfaces that should be coded as follows:

    Bubbles tb = new TestBubbles();
    tb.addAir(type, sizeOne, sizeTwo);
    

    That way you later could exchange TestBubbles with SuperTrooperTestBubbles which implements the same Interface by only changing one line of code, and the rest will work:

    Bubbles tb = new SuperTrooperTestBubbles();
    tb.addAir(type, sizeOne, sizeTwo);
    

    Where

    public class SuperTrooperTestBubbles implements Bubbles { .... 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to understand java behaviour. Using this interfaces : public interface IA {}
I am trying to understand interfaces in Java and have this task to do
I'm really rolling up my sleeves and trying to understand Java annotations for the
I am trying to understand the concept of an interface in java so far
I'm trying to write a scanner for my C/C++/C#/Java/D-like programming language that I'm designing
I'm trying to understand how java.util.Calendar.get(java.util.Calendar.WEEK_OF_YEAR) works, but it seems that I'm missing some
I am trying to understand connection pooling in java , i am using jsp,
I am trying to understand Java. Let's assume I have an ArrayList of size
I am trying to understand static analysis of Java bytecode/source-code. These terms frequently come
I'm trying to understand the contract of drainPermits in the Java Semaphore class The

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.