Results 1 to 3 of 3
  1. #1
    kprime is offline Member
    Join Date
    Feb 2013
    Rep Power

    Default Inheritance question


    I have a question about inheritance. I read that every class inherits from Object. Say I have a Base class that overrides equals and I have a Derived class that extends Base. So if I called super.equals() from code in the Derived class that calls the equals method of Base correct? Since every class inherits from Object, is the equals method from Object still available to code in the Derived class? How would one call the equals method from Object in Derived.

    Also if I override method in Derived, there is not way to call the Base method outside of the Derived class with an instance of Derived correct? In other words a method call is always polymorphic?

    Thank you.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power

    Default Re: Inheritance question

    What happened when you put together a small example program that tested your assumptions?
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  3. #3
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Rep Power

    Default Re: Inheritance question

    If the Derived class does need the equals method in Object and not the equals method in Base class then I would say that you hierarchy is wrong. If you are 100% positive that the hierarchy is correct then the Base class should not override the equals method.

Similar Threads

  1. Inheritance question
    By juxta in forum New To Java
    Replies: 2
    Last Post: 12-11-2012, 10:24 PM
  2. Inheritance hierarchy question
    By IAmACodingNoob in forum New To Java
    Replies: 3
    Last Post: 04-06-2012, 12:55 AM
  3. inheritance question
    By Jaevko in forum New To Java
    Replies: 7
    Last Post: 08-31-2011, 07:30 AM
  4. Question about inheritance
    By hei1233212000 in forum New To Java
    Replies: 3
    Last Post: 11-12-2010, 11:38 AM
  5. a question about inheritance
    By litojs in forum New To Java
    Replies: 8
    Last Post: 11-10-2008, 10:07 PM

Posting Permissions

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