Method Overriding
A subclass method overrides its superclass method if it has the same name a parameter types as its superclass. Output: 4 sides You can notice the subclass and the superclass…
Static methods in Java
Why static methods? Take two people (two objects below). The getName method will return the name of the first person, and the second person, but there's something different about calculateAge…
Implicit and Explicit Parameters
There are two types of methods in Java: Implicit Parameters & Explicit Parameters Explicit Parameters "int side" in the getArea method is an EXPLICIT parameter. Implicit Parameters str1 is a…
Method Overloading
When you give two or more methods the same name within the same class you are overloading the method name. Overloaded methods have something different in their parameter lists. Java…
toString method
Any time that you need a string representation of an object, we use toString. Outputs: The contructor for this is 5/6/7 Since 'this' is used, in the system.out.printf statement, it…
Passing an unknown number of variables to a method
Sometimes you want to build a method and you don't know how many arguments it needs. For example, a method that averages a bunch of numbers. This example shows how…