-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMethodActivity.java
More file actions
49 lines (34 loc) · 1.03 KB
/
MethodActivity.java
File metadata and controls
49 lines (34 loc) · 1.03 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package javaTraining.module1;
public class MethodActivity {
// TODO #1: write a method which will output "Hello!"
public static void getPub(){
System.out.println("Hello!");
}
// END TODO #1
// TODO #2: write a static method which will output "Hello!"
public static void pub2(){
System.out.println("Hello!");
}
// END TODO #2
// TODO #3: Write method which returns a sum of 2 numbers. 2 numbers should be passed as parameters.
public int getSumm(int a, int b){
int sum;
sum = a+b;
return sum;
}
// END TODO #3
public static void main(String arg[]){
// TODO #4: Invoke a method from TODO #1. HINT - main() method is a STATIC method
MethodActivity met = new MethodActivity();
met.getPub();
// END TODO #4
// TODO #5: Invoke a method from TODO #2. (Try to invoke it 2 ways possible)
pub2();
// END TODO #5
// TODO #6: Invoke a method from 3rd 'TODO'. Assign return value of this method to a variable and output it
int a =2;
int b =5;
System.out.println(met.getSumm(a ,b));
// END TODO #6
}
}