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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:49:03+00:00 2026-05-22T14:49:03+00:00

I want to write an abstract method but the compiler persistently gives this error:

  • 0

I want to write an abstract method but the compiler persistently gives this error:

abstract methods cannot have a body

I have a method like this:

public abstract boolean isChanged() {
    return smt else...
}

What is wrong here?

  • 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-22T14:49:04+00:00Added an answer on May 22, 2026 at 2:49 pm

    Abstract methods means there is no default implementation for it and an implementing class will provide the details.

    Essentially, you would have

    abstract class AbstractObject {
       public abstract void method();
    }
    
    class ImplementingObject extends AbstractObject {
      public void method() {
        doSomething();
      }
    }
    

    So, it’s exactly as the error states: your abstract method can not have a body.

    There’s a full tutorial on Oracle’s site at: http://download.oracle.com/javase/tutorial/java/IandI/abstract.html

    The reason you would do something like this is if multiple objects can share some behavior, but not all behavior.

    A very simple example would be shapes:

    You can have a generic graphic object, which knows how to reposition itself, but the implementing classes will actually draw themselves.

    (This is taken from the site I linked above)

    abstract class GraphicObject {
        int x, y;
        ...
        void moveTo(int newX, int newY) {
            ...
        }
        abstract void draw();
        abstract void resize();
    }
    
    class Circle extends GraphicObject {
        void draw() {
            ...
        }
        void resize() {
            ...
        }
    }
    class Rectangle extends GraphicObject {
        void draw() {
            ...
        }
        void resize() {
            ...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a method that I want to be transactional in the abstract sense.
I want to write a Swing application in Griffon but I am not sure
I want to write a little DBQuery function in perl so I can have
I want to write something like the following: internal class InternalData { } public
Working with C#. I have an abstract class that I use to read/write settings
We have a bug to fix, and like any good TDD practitioner, I want
Essentially I want to do something like this: class Shape class CoordSystem class C3D(val
I have an abstract generic class public abstract class Foo<TType> with an abstract method
Hello I want write my own desktop sharing application in Java. The application should
I want to write a command that specifies the word under the cursor in

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.