forked from kaal-coder/hacktoberfest2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram_49.java
More file actions
44 lines (43 loc) · 790 Bytes
/
Copy pathprogram_49.java
File metadata and controls
44 lines (43 loc) · 790 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
abstract class animal
{
void legs()
{
System.out.println("all animals have four legs");
}
abstract void sound();
abstract void eat();
}
class dog extends animal
{
@Override
void sound()
{
System.out.println("bow bow...");
}
void eat()
{
System.out.println("it eats meat");
}
}
class cow extends animal
{
@Override
void sound()
{
System.out.println("ooo ooo...");
}
void eat()
{
System.out.println("it eats grass");
}
}
class absclass
{
public static void main(String[] args)
{
dog d=new dog();
cow c=new cow();
d.sound(); d.eat(); d.legs();
c.sound(); c.eat(); c.legs();
}
}