Results 1 to 3 of 3
Like Tree3Likes
  • 1 Post By JosAH
  • 2 Post By Tolls

Thread: abstract class

  1. #1
    oszc is offline Member
    Join Date
    Aug 2011
    Posts
    20
    Rep Power
    0

    Default abstract class

    hi,all
    since we had to override a concrete method in an abstract class ,why java language do not forbid concrete method in abstract class , all using abstract method?

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,661
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by oszc View Post
    hi,all
    since we had to override a concrete method in an abstract class ,why java language do not forbid concrete method in abstract class , all using abstract method?
    An abstract class cannot be directly instantiated (only concrete subclasses thereof can) and it may have abstract methods but it doesn't need to. Of course a subclass needs all of its methods to be implemented, either by itself or by a super class.

    kind regards,

    Jos
    oszc likes this.
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default

    Not sure I understand the question.
    Do you have an example?
    Because the way the question sounds at the moment is that if I have:
    Java Code:
    public abstract class Test {
        public void someMethod() {
        }
    }
    you seem to think that extending that class will force you to override the someMethod, even though it's not abstract. Which isn't true.
    oszc and JeffGrigg like this.

Similar Threads

  1. abstract method-abstract class
    By durgaprasad1407 in forum New To Java
    Replies: 1
    Last Post: 04-29-2011, 06:58 PM
  2. Replies: 4
    Last Post: 04-14-2011, 11:42 AM
  3. How can I call abstract class methods from another class
    By srinivas2828 in forum New To Java
    Replies: 13
    Last Post: 03-12-2010, 02:33 PM
  4. Replies: 6
    Last Post: 02-11-2009, 10:51 AM
  5. Replies: 0
    Last Post: 04-02-2008, 07:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •