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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:49:13+00:00 2026-06-04T05:49:13+00:00

There is an example of Implementing an Interface in Java tutorial. I have repeated

  • 0

There is an example of “Implementing an Interface” in Java tutorial. I have repeated this example but it doesn’t work. NetBeans shows the mistake on te left of RectanglePlus class declaration. And mistake is:

rectangleplus.RectanglePlus is not abstract and does not override
abstract method isLargerThan(rectangleplus.Relatable) in
rectangleplus.Relatable

I did the same as written in tutorial. Why it shows the mistake? Here is my implementation of the project.

  1. The name of the project is RectanglePlus.
  2. The name of the package is rectangleplus.

1st file in the project is Interface Relatable:

package rectangleplus;

public interface Relatable {
   int isLarger(Relatable other);   
}

2nd file in the project is Main Class RectanglePlus with helper class Point:

package rectangleplus;

public class RectanglePlus implements Relatable {

    public int width = 0;
    public int height = 0;
    public Point origin;

    // four constructors
    public RectanglePlus() {
        origin = new Point(0, 0);
    }
    public RectanglePlus(Point p) {
        origin = p;
    }
    public RectanglePlus(int w, int h) {
        origin = new Point(0, 0);
        width = w;
        height = h;
    }
    public RectanglePlus(Point p, int w, int h) {
        origin = p;
        width = w;
        height = h;
    }

    // a method for moving the rectangle
    public void move(int x, int y) {
        origin.x = x;
        origin.y = y;
    }

    // a method for computing
    // the area of the rectangle
    public int getArea() {
        return width * height;
    }

    // a method required to implement
    // the Relatable interface
    public int isLargerThan(Relatable other) {
        RectanglePlus otherRect 
            = (RectanglePlus)other;
        if (this.getArea() < otherRect.getArea())
            return -1;
        else if (this.getArea() > otherRect.getArea())
            return 1;
        else
            return 0;               
    }

   public static void main(String[] args) {
      // TODO code application logic here
   }
}

class Point {
   int top;
   int left;
   int x;
   int y;

   public Point(int t, int l) {
      top = t;
      left = l;
   }
}

Why there is nothing said about abstraction in the tutorial example? Should the tutorial example work without mitakes?

Thank you.

  • 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-04T05:49:14+00:00Added an answer on June 4, 2026 at 5:49 am

    In the interface, you declare the method isLarger but in the class you declare isLargerThan Change one to the other name and it will go fine.

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

Sidebar

Related Questions

is there any example on using java method to call rhino-javascript function and return
This question concerns the reflection mechanisms of the java programming language. I have an
Currently I have an object implementing the IComparable interface (ASP.NET 3.5, VB). When I
Is there a way to get by this? For example, my XML: <group> <idExt>new
I have a this java application i am working on to get more experience
I have a list of items implementing an interface. For the question, let's use
Is there an example of an OAuth implementation or profile which uses multiple authorization
Is there any example on DOS Batch - Find and Replace command for files?
Is there any example for a Real Time Chart using the DexExpress in ASP.Net?
There is an example on Adobe livedocs for using states : <!-- Define one

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.