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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:44:02+00:00 2026-06-17T19:44:02+00:00

So I have a class full of junit tests and a class full of

  • 0

So I have a class full of junit tests and a class full of methods that perform binary operations. The tests are checking to see if I have the right values at certain points.

I am failing a lot of tests because of what I believe to be is the return type. For example I get the message

junit.framework.ComparisonFailure: null expected:<[000]> but was <[BinaryNumber@4896b555]>

If I’m understanding this it’s saying that it was looking for an array containing 000 but it got a BinaryNumber (which is the required return type). To help clarify here is one of the methods.

    public BinaryADT and(BinaryADT y) {
    int[] homeArr = pad(((BinaryNumber) y).getNumber());
    int[] awayArr = ((BinaryNumber) y).pad(getNumber());

    int[] solution = new int[awayArr.length];
    int i = 0;
    String empty = "";

    while(i < solution.length){
        solution[i] = homeArr[i] & awayArr[i];
        i++;
    }
    for(int indexF = 0; indexF < solution.length; indexF++){
        empty = empty + solution[indexF];
    }
    System.out.println(empty);

    return new BinaryNumber(empty);
}

Am I understanding this right? If not could someone please explain? I’d also like to point out that this is for my homework but I’m not asking for answers/someone to do it for me. Just a point in the right direction at most.

I will gladly clarify more if it is needed (I didn’t want to bog everything down).

Also this is my first post on here. I tried to keep to the formatting suggestions but I apologize if anything is sub-par.

As suggested here is the test method

public void testAnd1()
{
    BinaryADT x = new BinaryNumber("111");
    BinaryADT y = new BinaryNumber("000");
    BinaryADT z = x.and(y);
    assertNotSame(x,z);
    assertNotSame(y,z);
    assertEquals("000",z.toString());
}
  • 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-17T19:44:04+00:00Added an answer on June 17, 2026 at 7:44 pm

    Whenever you see the output of “toString()” like ClassName@SomeNumber, then you can be sure that toString() method is not implemented for that class (unless toString() method implementation itself is not like this).

    In your case, expected value is [000], but you are getting [BinaryNumber@4896b555].

    Try to implement toString() method in BinaryNumber class and return the value from this method as per assertEquals() expects. This should solve the problem.

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

Sidebar

Related Questions

My application has a class full of functions that perform various operations. These operations
I have the following junit tests in an UTF-8 encoded file. public class EncodingTest
I have a class called SqliteImageAccess that is going to have various methods that
I have this class that tries multiple methods of getting data from Google maps
While writing yet another class full of methods that access database tables to work,
I have a Python class full of static methods. What are the advantages and
In specializing a class template, I would like to have one specialization target full-blown
I have class that extend FragmentActivity in it I add fragment to layout as
I have class grades that I need to check if a specific grade is
I have a constants class full of a bunch of final static strings. I

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.