-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathInterfaceDemo.java
More file actions
172 lines (138 loc) · 3.76 KB
/
InterfaceDemo.java
File metadata and controls
172 lines (138 loc) · 3.76 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import java.util.List;
import java.util.ArrayList;
import java.util.Date;
import java.awt.event.*;
// 100 % ABSTRACT (ALL ARE ABSTRACT METHODS + CONSTANTS)
interface DBOperations{ // abstract interface DBOperations
int MAX = 100; // public static final int MAX = 100;
boolean create(String userid, String password); // public abstract boolean create (String userid, String password)
List read(); // public abstract List read();
// Java 8
public default void logDBTime(){
show();
System.out.println("DB Time "+new Date());
}
// Java 9
private void show(){
System.out.println("I am the Show Fn of DBOperations");
}
// Java 8
public static void disp(){
System.out.println("I am Static in INterface");
}
}
// Partial Implementation
abstract class PosGres implements DBOperations{
@Override
public boolean create(String userid, String password){
return true;
}
}
interface AuthOperations{
int MAX = 200;
void login();
boolean create(String userid, String password);
}
interface MixOperations extends DBOperations , AuthOperations{
int MAX = 300;
}
class H2 implements MixOperations{
@Override
public boolean create(String userid, String password) {
// TODO Auto-generated method stub
System.out.println(DBOperations.MAX + AuthOperations.MAX + MixOperations.MAX);
return false;
}
@Override
public List read() {
// TODO Auto-generated method stub
return null;
}
@Override
public void login() {
// TODO Auto-generated method stub
}
}
class PosGresNew extends PosGres{
@Override
public List read() {
// TODO Auto-generated method stub
return null;
}
}
class Db{
}
// Fully Implementation
//ERROR class MySQL implements DBOperations, AuthOperations extends Db{
class MySQL extends Db implements DBOperations, AuthOperations{
@Override
public boolean create(String userid, String password){
System.out.println("Added in MySQL DB");
return true;
}
@Override
public List read(){
return new ArrayList();
}
@Override
public void login() {
// TODO Auto-generated method stub
}
}
class Oracle implements DBOperations{
@Override
public boolean create(String userid, String password) {
// TODO Auto-generated method stub
return false;
}
@Override
public List read() {
// TODO Auto-generated method stub
return null;
}
}
/*class W implements WindowListener{
@Override
public void windowOpened(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowClosing(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowClosed(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowIconified(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowDeiconified(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowActivated(WindowEvent e) {
// TODO Auto-generated method stub
}
@Override
public void windowDeactivated(WindowEvent e) {
// TODO Auto-generated method stub
}
}*/
class W2 extends WindowAdapter{
@Override
public void windowClosing(WindowEvent e){
}
}
public class InterfaceDemo {
public static void main(String[] args) {
WindowAdapter w ;
WindowListener l;
DBOperations.disp();
// H2 h2 = new H2();
// h2.create("Amit", "11111");
// h2.logDBTime();
}
}