-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMethods.java
More file actions
32 lines (26 loc) · 995 Bytes
/
Methods.java
File metadata and controls
32 lines (26 loc) · 995 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
25
26
27
28
29
30
31
32
import java.util.Scanner;
public class Methods {
public void display(){
//Non static and non Parametrised Method
System.out.println("This is Non Static and Non Argument Method");
}
public void sumOfTwoNum(int num1,int num2){//Non Static method and Parametrised
System.out.println("Sum Of Two Number : "+(num1+num2));
}
public static int Multiply(int num,int num2){
//static and parametrised method it will return a value which is Integer type
int res = num * num2;
return res;
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
int num2 = scan.nextInt();
//to access Non static method you will have to create a object
Methods obj = new Methods();
obj.display();
obj.sumOfTwoNum(num,num2);
int val = Multiply(num,num2);
System.out.println(val);
}
}