Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: What is the overiding in java?

  1. #1
    Junior Member
    Join Date
    May 2014
    Location
    Islamabad, Pakistan
    Posts
    3
    My Mood
    Stressed
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question What is the overiding in java?

    Hey! I wanted to ask that what is overiding in java? It is confusing me allot. I got the point of overloading but in case of overriding, I am unable to get what it is?
    Please help!

    SA.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: What is the overiding in java?

    So you know that with overloading, several methods or constructors can have the same name but take different parameters. Overriding is a method with exactly the same signature as an extended or parent class so that the derived class' method overrides the parent class' method.

    The toString() method is a good example that you should have learned about. The Object class provides a toString() method, but a programmer will usually override the toString() method with his/her own version in order to present the class appropriately when printed using the default output.

  3. #3
    Member
    Join Date
    Feb 2014
    Posts
    180
    Thanks
    0
    Thanked 48 Times in 45 Posts

    Default Re: What is the overiding in java?

    To add to GragBrannon's succinct explanation, Java Inheritance gives a good rundown on method overriding by starting with inheritance, followed by defining overriding methods in a subclass, an Annotation to use when overriding a method, and finally how fields cannot be overridden in a subclass.

    Another good resource is Java - Overriding, which goes into greater depth by covering the rules for method overiding. While you're at it, you might want to also go through the next page in the tutorial that links polymorphism to method overriding.

    To round this off, take a look at Overriding and Hiding Methods (The Java™ Tutorials > Learning the Java Language > Interfaces and Inheritance), which covers a similar concept - method hiding - that is applicable to static methods. (You may want to skip the Interface Methods section though. This is a new feature introduced in Java 8, and it's quite confusing.)

  4. #4
    Junior Member
    Join Date
    Dec 2013
    Posts
    13
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: What is the overiding in java?

    Overriding method: same signature (same return type, list of parameters, name of method), but do slightly different task.
    Overloading method: same name of method, but different list of parameters.

Similar Threads

  1. Problems with understanding inheritance/method overiding
    By Jackbruns28 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 26th, 2013, 08:50 PM