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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:42:32+00:00 2026-05-26T03:42:32+00:00

SEE THE EDIT HALFWAY DOWN THE POST. I’m new to java and all the

  • 0

SEE THE EDIT HALFWAY DOWN THE POST.

I’m new to java and all the formal declarations of inheritance are getting me a little confused.

I have a interface like so:

public interface A{
    public void one();
    public void two();
}

and then I have two classes like so:

public class B implements A{
    private int num;

    public void one(){
        ...
    }
    public void two(){
        ...
    }
    public B(){
        this.num = 1;
    }
}

public class C extends B{
    public C(){
        super();
    }
}

then I have a driver class like so:

public class Driver{
    public static void main(String [] args){
        A a_array[] = new A[5];

        for(int i=0; i<6; i++){
           if(i%2==0){
               a_array[i] = new B();
           }
           else{
               a_array[i] = new C();
           }
        }
    }
}

Basically, given an array of interfaces I am trying to implement various classes that implement that interface.

Now my guess is there are several things wrong with this implementation, but I seem unable to sniff them out. Primarily right now I am getting the error ‘B() is not abstract and does not implement method one()’.


EDIT:

alright lets try this…
the interface:

public interface Shape{
     public double calcAread();
     public double calcPerimeter();
}

the implementing class:

public class Rectangle implements Shape{
    private double length;
    private double width;

    public double calcArea(){
         return this.length*this.width;
    }

    public double calcPerimeter(){
         return (this.length*2)+(this.width*2);
} 

    public Rectangle(double length, double width){
        this.length=length;
        this.width=width;
    }
    // then some other methods including the set methods
}

the extending class:

public class Square extends Rectangle{
    public Square(){
        super();
    }

    public Square(double sideLength){
         super.setLength(sideLength);
         super.setWidth(sideLength);
    }
    // some more methods
}

I can’t think of very much more that would be useful other than to mention that there are other inheriting and extending classes off of these but they follow exactly the same design and sentax.

No errors when I compile shape, but the ‘Rectangle is not abstract and does not override abstract method calcAread() in Shape’ error is tripped when I compile the Rectangle class.

Hopefully this will be more enlightening.

Thanks

  • 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-05-26T03:42:32+00:00Added an answer on May 26, 2026 at 3:42 am

    What you’ve provided as example code will work just fine. My suspicion is that your exact code and your example code differ.

    Without seeing the exact error message and B class it’s hard to say, but I’m willing to bet you have either a return value or parameter difference between the definition of one in your interface and your one in your implementation.

    Edit: Here’s what I see as the problem. Your interface’s method is called “calcAread“. Is that d supposed to be on the end?

    public double calcAread();
    

    Because it’s missing inside Rectangle

    public double calcArea()
    

    That’s going to cause a problem. It makes me wonder how @Zohaib managed to compile it actually!

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

Sidebar

Related Questions

EDIT: This problem has been solved. See below. Hey all. I'm building an iPhone
EDIT: See my working code in the answers below. In brief: I have a
Intro: EDIT: See solution at the bottom of this question (c++) I have a
EDIT: See this in action here: http://jsbin.com/emobi/5 -- and that's using mouseenter/mouseleave. I have
I have a Controller with two Edit methods (see below). When I submit the
See updated input and output data at Edit-1. What I am trying to accomplish
EDIT: I would really like to see some general discussion about the formats, their
Edit: I have solved this by myself. See my answer below I have set
I receive this message (see image below) when I try to edit in debugging.
I have just successfully installed CakePHP and I see that I can edit 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.