Function overloading

Function overloading happens when a class has multiple methods with the same name. If we define a getData method twice in our class, we can say that the getData function is overloaded, as shown in the following code:

package coreJava;//function overloadingpublic class childlevel extends childClassDemo {    public void getData(int a)    {         }    public void getData(String a)    {         }    public static void main(String[] args) {        childlevel cl=new childlevel();        cl.getData(2);        cl.getData("hello")    }}

There are a few rules that we need to remember while using multiple instances of a function with the same name. The first rule is that the number of arguments present in the function-overloaded method should be different, and the second is that ...

Get Hands-On Automation Testing with Java for Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.