O'Reilly logo

Java 2™ Programmer Exam Cram™ 2 (Exam CX-310-035) by Marcus Green, Bill Brogden

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Overloading and Overriding

The terms overloading and overriding are applied to situations in which you have multiple Java methods with the same name. Within a particular class, you can have more than one method with the same name as long as they have different input parameter types. This is described as overloading the method name. To continue the book example, the BookElement class might have methods declared as follows:

public void addText( String txt )
public void addText( String[] lines )

You would say that addText has been overloaded. The Java compiler can distinguish between calls to these two methods because they have different signatures. The number, type, and order of the input parameters plus the method name determine the signature. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required