- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx10Class.java
More file actions
Latest commit
32 lines (26 loc) · 1.16 KB
/
Copy pathEx10Class.java
File metadata and controls
32 lines (26 loc) · 1.16 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
packageJavaEntry;
publicclassEx10Class { // Class is a bluprint
finalintx = 10; // With final keyword we cant modify the x value.
inty = 20;
publicintmultiply(inta, intb){
returna * b;
}
staticintadd(inta, intb){
returna + b;
}
publicstaticvoidmain(String[] args){
Ex10ClassclassObj = newEx10Class(); // we can create a multiple object using the same class.
Ex10ClassclassObj2 = newEx10Class(); // we can create a multiple object using the same class.
intsum = classObj.multiply(classObj.x, classObj2.y); // Call class public method using object.
intadd = add(classObj.x, classObj2.y); // Call class static method direct class.
System.out.println(classObj.x);
System.out.println(classObj2.y);
System.out.println("Total Multiply: " + sum);
System.out.println("Total Add: " + add);
classObj2.y = 30; // we can modify the object.
System.out.println(classObj2.y);
// Import class from another class
Ex10ClassImportimportClass = newEx10ClassImport();
importClass.printMyName("Banti Shaw");
}
}