- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx16ClassAbsInterface.java
More file actions
Latest commit
74 lines (62 loc) · 2.18 KB
/
Copy pathEx16ClassAbsInterface.java
File metadata and controls
74 lines (62 loc) · 2.18 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
packageJavaEntry;
// abstract class: using it we hiding certain details and showing only essential information to the user.
// Interfaces, hide certain details and only show the important details of an object.
abstractclassUserDetails {
Stringname = "Banti Shaw";
StringuniversityName = "SMU";
StringgetUserDetails(){
returnname + " " + universityName;
}
}
classForUseUserDetailsextendsUserDetails {
publicStringgetName = getUserDetails();
}
interfaceStudent {
Stringname = "Ganesh";
StringuniversityName = "Unknown";
defaultStringgetStudentDetails(){
returnname;
}
}
classForInterfaceUseimplementsStudent {
publicStringstudentName = getStudentDetails();
}
// enum is a special "class" that represents a group of constants (unchangeable variables, like final variables).
enumProcess {
TODO,
INDEVELOPMENT,
REVIEW,
DONE
}
publicclassEx16ClassAbsInterface {
publicstaticvoidmain(String[] args){
// UserDetails userObj = new UserDetails(); // We can't create the object with abstract class.
ForUseUserDetailsextendedUserObj = newForUseUserDetails();
System.out.println(extendedUserObj.getName);
ForInterfaceUseinterfaceStudentObj = newForInterfaceUse();
System.out.println(interfaceStudentObj.studentName);
ProcesscurrState = Process.TODO;
ProcessdevState = Process.INDEVELOPMENT;
System.out.println(currState + " " + devState);
switch(currState){
caseTODO:
System.out.println("Work is on " + currState + " state");
break;
caseINDEVELOPMENT:
System.out.println("Work is on " + currState + " state");
break;
caseREVIEW:
System.out.println("Work is on " + currState + " state");
break;
caseDONE:
System.out.println("Work is on " + currState);
break;
default:
System.out.println("No Work");
break;
}
for(ProcessenumItem : Process.values()){
System.out.println("Process name - " + enumItem);
}
}
}