Uncategorized

Uncategorized

Overloading and Overriding “Overloading” and “Overriding” are two important concepts that are part of the Java SE Programmer I exam. This concept, along with other core Java concepts, is important for both a developer’s perspective and for the certification exam. Overloading will be discussed first, then we will move on to overriding. Overloading:’Overloading’ as the name suggests is done by creating multiple methods with same name – but with different argument lists, return type and access modifier. It is important to remember that a method can only be considered overloaded if it has a different argument set. It is not necessary to specify a different access modifier or return type. Take the following example: In the above example we are overloading the method “area” to find the area for different figures (rectangles, squares, circles). The argument lists of all three methods are different. Because they all have different argument lists, they are all overloaded methods. They also have different return value. Overloading is the simpler concept. These are the key takeaways from the exam. Any number of overloaded method can exist in the same sub-class or class. However, the argument lists of the overloaded methods must be different. Overloaded methods can be considered different methods. They have the same name, but different argument lists, return types, and access modifiers.

Overriding: We will next discuss the concept “overriding”. Sub-classes can use overriding to modify the functionality of a particular method. The concept of “overriding” is

Read More