-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabstraction.java
More file actions
49 lines (38 loc) · 918 Bytes
/
Copy pathabstraction.java
File metadata and controls
49 lines (38 loc) · 918 Bytes
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
import javax.security.auth.callback.ChoiceCallback;
public class abstraction {
public static void main(String args[]){
Cow c1 = new Cow();
c1.run();
c1.color();
Chicken ch = new Chicken();
ch.run();
ch.color();
}
}
abstract class Animal{
String color;
void eat(){ //non-abtract method
System.out.println("Animal is eating");
}
abstract void run(); // abstract method
abstract void color();
}
class Cow extends Animal{
void run(){
System.out.println("Run on 4 legs");
}
void color(){
System.out.println("cow color is brown");
}
void type(){
System.out.println("Cow type is jersy");
}
}
class Chicken extends Animal{
void run(){
System.out.println("Run on 2 legs");
}
void color(){
System.out.println("Chicken color is yellow");
}
}