Hands-On Automation Testing with Java for beginners by Rahul Shetty
Author:Rahul Shetty [Rahul Shetty]
Language: eng
Format: epub
Tags: COM051280 - COMPUTERS / Programming Languages / Java, COM051000 - COMPUTERS / Programming / General, COM051330 - COMPUTERS / Software Development and Engineering / Quality Assurance and Testing
Publisher: Packt Publishing
Published: 2018-09-28T11:23:45+00:00
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 overloading
public 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 the argument data type should be different. If we keep both the getData methods with the int a argument, it will throw an error, so we need to have a different number of arguments for each method. Now, when you print these, you'll get the outputs of 2 and hello. We can see that two different arguments are printed, but with the same method name. Let's add one more getData instance with two arguments, as follows:
public void getData(int a, int b)
{
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Coding Theory | Localization |
Logic | Object-Oriented Design |
Performance Optimization | Quality Control |
Reengineering | Robohelp |
Software Development | Software Reuse |
Structured Design | Testing |
Tools | UML |
Deep Learning with Python by François Chollet(12523)
Hello! Python by Anthony Briggs(9868)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9758)
The Mikado Method by Ola Ellnestam Daniel Brolund(9748)
Dependency Injection in .NET by Mark Seemann(9294)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8259)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7742)
Grails in Action by Glen Smith Peter Ledbrook(7668)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7518)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(6746)
Microservices with Go by Alexander Shuiskov(6513)
Practical Design Patterns for Java Developers by Miroslav Wengner(6411)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6389)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6379)
Angular Projects - Third Edition by Aristeidis Bampakos(5769)
The Art of Crafting User Stories by The Art of Crafting User Stories(5300)
NetSuite for Consultants - Second Edition by Peter Ries(5244)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5062)
Kotlin in Action by Dmitry Jemerov(5020)
