scjp party n.
Skip this Video
Loading SlideShow in 5 Seconds..
SCJP Party PowerPoint Presentation
Download Presentation
SCJP Party

Loading in 2 Seconds...

play fullscreen
1 / 14

SCJP Party - PowerPoint PPT Presentation

  • Uploaded on

SCJP Party. Chapter 2: Object Orientation. Inheritance Overload and Override Constructors Statics. Objectives. Java supports only single inheritance!. Inheritance. Inheritance. Inheritances. The argument list must exactly match that of the overridden method

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

SCJP Party

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
scjp party

SCJP Party

Chapter 2: Object Orientation



  • Overload and Override
  • Constructors
  • Statics
overridden methods

The argument list must exactly match that of the overridden method

  • The return type must be the same as, or a subtype of, the return type declared in the original overridden method in the superclass.
  • The access level can't be more restrictive than the overridden method's.
  • The overriding method CAN throw any unchecked (runtime) exception
  • The overriding method must NOT throw checked exceptions that are new
  • or broader than those declared by the overridden method
Overridden Methods
overloaded methods

Overloaded methods MUST change the argument list.

  • Overloaded methods CAN change the return type.
  • Overloaded methods CAN change the access modifier.
  • Overloaded methods CAN declare new or broader checked exceptions.
Overloaded Methods

Just remember, the reference type (not the object type) determines which overloaded method is invoked!

  • To summarize, which overridden version of the method to call (in other words, from which class in the inheritance tree) is decided at runtime based on object type, but which overloaded version of the method to call is based on the reference type of the argument passed at compile time

Constructors can use any access modifier, including private.

  • The constructor name must match the name of the class.
  • Constructors must not have a return type
  • The default constructor is ALWAYS a no-arg constructor.
  • The first line in a constructor must be a call to super() or a call to this()
  • You cannot make a call to an instance method, or access an instance variable, until after the super constructor runs.
  • Abstract classes have constructors, and those constructors are always called when a concrete subclass is instantiated.
  • Interfacesdo not have constructors. Interfaces are not part of an object's inheritance tree.

Static methods can't be overridden

  • Static method cannot access an instance (non-static) variable
  • Static method cannot access a non-static method
  • Static method can access a static method or variable