-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path05_Methods.java
More file actions
39 lines (35 loc) · 1.03 KB
/
05_Methods.java
File metadata and controls
39 lines (35 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
class Examination {
// Without Object || With static method
public static void main (String ...args) {
System.out.println("Results: ");
cgpaOfStudent(args[0]);
}
// create a function :
// returnType functionName (Arguments) {}
static void cgpaOfStudent(String cg) {
System.out.println("Your CGPA is " + cg);
}
}
class Examination {
public static void main (String ...args) {
System.out.println("Results: ");
cgpaOfStudent(args[0]);
}
// Here if we do not use static method and call the method
// without object, we will get an error.
void cgpaOfStudent(String cg) {
System.out.println(cg);
}
}
class Examination {
// With Object || Without static method
public static void main (String ...args) {
System.out.println("Results: ");
// Create Object
Examination E1 = new Examination();
E1.cgpaOfStudent(args[0]);
}
void cgpaOfStudent(String cg) {
System.out.println("Your CGPA is" + cg);
}
}