[go: up one dir, main page]

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

Lab1 2

Uploaded by

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

Lab1 2

Uploaded by

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

Lab-1

 Method Overloading
public class OverloadExample {

// Method to add two integers

public int add(int a, int b) {

return a + b;

// Overloaded method to add three integers

public int add(int a, int b, int c) {

return a + b + c;

// Overloaded method to add two doubles

public double add(double a, double b) {

return a + b;

public static void main(String[] args) {

OverloadExample example = new OverloadExample();

// Calling the method to add two integers

System.out.println("Sum of 5 and 10: " + example.add(5, 10));

// Calling the overloaded method to add three integers

System.out.println("Sum of 5, 10, and 15: " + example.add(5, 10, 15));

// Calling the overloaded method to add two doubles

System.out.println("Sum of 5.5 and 10.5: " + example.add(5.5, 10.5));

You might also like