0% found this document useful (0 votes)
16 views1 page

Java Method Overloading Example

This Java code defines a NoVararg class with overloaded sumNumber methods that take two or three int parameters and return their sum, and a main method that creates an instance and calls each sumNumber method to print the results.

Uploaded by

study.drizzle
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views1 page

Java Method Overloading Example

This Java code defines a NoVararg class with overloaded sumNumber methods that take two or three int parameters and return their sum, and a main method that creates an instance and calls each sumNumber method to print the results.

Uploaded by

study.drizzle
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

//without using variable length program

class NoVararg {
public int sumNumber(int a, int b){
return a+b;
}
public int sumNumber(int a, int b, int c){
return a+b+c;
}
public static void main( String[] args ) {
NoVararg obj = new NoVararg();
[Link]([Link](1, 2));
[Link]([Link](1, 2, 3));
}}

You might also like