Java Programming: 16 - Overriding methods, drawing on a frame

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
1,091
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Dec 31, 2011

In this tutorial, we continue learning about inheritance by covering overriding methods. Technically, overriding methods isn't specific to inheritance, but we will learn more about that after a couple more videos.

You can override inherited methods by creating a method with the same signature as one that is inherited (same name, return type, and parameters). Or you can use Eclipse's code assisting to do that for you, as I do in this video.

You can use the super keyword to reference the instance of the base class, and use it to call methods or access variables. This is useful for when you need to override a method to add additional functionality, rather than replace it entirely.

The @Override is called an annotation, is optional, and isn't important to learn about right now.

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (CodeMonkeyCharlie)

  • so what does super. do?? IM SO LOST

  • @15johnkim super refers to the base class instance. The way inheritance works is that there is a chain of instantiation, where ultimately the last link is the class you're actually creating an instance of, and the first is Object. In our case here, we have Object > Base > Subclass.

    You can think of using "super" inside of Subclass as working with an instance of Base, just like how "this" is the instance of Subclass. I'll cover it in more detail in a future video.

  • no 17? is it the end?

    

  • @SuperDpunisher Definitely not the end, I'll be making more when I find the time

  • One question: Do you recommend any other tutorials I could use to broaden my knowledge?

  • @Gibbonator42685 Check out Richard Buckland from UNSW as well. He's also a brilliant lecturer.

Top Comments

  • Whens the next one... plz say tomorrow

  • Great tutorials.. just keep up doing pls..

Video Responses

This video is a response to Java Programming: 15 - Intro to Inheritance
see all

All Comments (19)

Sign In or Sign Up now to post a comment!
  • Great videos, can't wait for more.

  • Absolutely great video. I've watched them all now and really looking forward to your next one. Please keep up the great work.

  • Very well done! This tutorial gives the simple way to learn Java programming basics.

  • Is 17 gonna be out soon?

  • Very very good work.

    Seriously.

    Just watched all of those sequentially and feel like I've really learned something.

    Thanks a lot for giving this to the Community.

    It will make my learning all the smoother.

    Can't wait for the following parts now.

  • Please add more. You are very easy to follow and understand.

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more