-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQue-21.java
More file actions
24 lines (24 loc) · 754 Bytes
/
Copy pathQue-21.java
File metadata and controls
24 lines (24 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/*Write a program to demonstrate method overloading by writing a test method which has no inputs and prints no input.
a) Accepts an integer and prints it.
b) Accepts 2 integers and prints.
c) Accepts a number of type double. Calculate its square and print it. */
//By: Parth Panjwani
class Que21 {
public static void main(String[] args) {
int a = 10;
int b = 20;
double c = 10.5;
print(a);
print(a, b);
print(c);
}
public static void print(int a) {
System.out.println("a: "+a);
}
public static void print(int a, int b) {
System.out.println("a: "+a+" b: "+b);
}
public static void print(double c) {
System.out.println("c: "+c*c);
}
}