-
Notifications
You must be signed in to change notification settings - Fork 0
/
OopsTest1.java
51 lines (41 loc) · 1.12 KB
/
OopsTest1.java
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
package com.example.selfprogrammingtest;
class EncapsulationDemo {
public void add(int a, int b) {
int c = a + b;
System.out.println("int sum is: " + c);
}
public void add(float a, float b) {
float c = a + b;
System.out.println("folat sum is: " + c);
}
}
class InheritanceDemo extends EncapsulationDemo {
public void add(int a, int b) {
int c = a + b;
System.out.println("Overide int sum is " + c);
}
}
interface Demo {
void run();
void walk();
}
class Rajnish implements Demo {
public void run() {
System.out.println("Rajnish is running");
}
public void walk() {
System.out.println("Rajnish is walking");
}
}
public class OopsTest1 {
public static void main(String[] args) {
EncapsulationDemo eDemo = new EncapsulationDemo();
eDemo.add(10, 10);
eDemo.add(10f, 10f);
InheritanceDemo iDemo = new InheritanceDemo();
iDemo.add(11, 20);
Rajnish rajnish = new Rajnish();
rajnish.run();
rajnish.walk();
}
}