Skip to content

Commit c409d56

Browse files
committed
simple inheritance demo
1 parent 6e8ea4d commit c409d56

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

LAB4/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
# OOP in Java - LAB 4
3+
4+
### Objective:
5+
To learn concepts of Inheritance, techniques to use it, concept of overriding, use of keyword
6+
super, abstract class and method.
7+
8+
## Acknowledgements
9+
10+
- [LAB 4 PDF](https://github.com/pray3m/JavaPrograms/blob/main/LAB3/lab%203(class%20and%20object).pdf)
11+
- [Q.N 1*](https://github.com/pray3m/JavaPrograms/blob/main/LAB4/SimpleInheritance.java)
12+
- [Q.N 2*](https://github.com/pray3m/JavaPrograms/blob/main/LAB4/BoxDemo.java)
13+
- [Q.N 3*](https://github.com/pray3m/JavaPrograms/blob/main/LAB4/BoxDemo.java)
14+
- [Q.N 4*](https://github.com/pray3m/JavaPrograms/blob/main/LAB4/BoxDemo.java)
15+
- [Q.N 5*](https://github.com/pray3m/JavaPrograms/blob/main/LAB4/BoxDemo.java)
16+
- [Q.N 6*](https://github.com/pray3m/JavaPrograms/blob/main/LAB4/BoxDemo.java)
17+
- [Q.N 7*](https://github.com/pray3m/JavaPrograms/blob/main/LAB4/BoxDemo.java)
18+
- [Q.N 8*](https://github.com/pray3m/JavaPrograms/blob/main/LAB4/BoxDemo.java)
19+
- [Q.N 9*](https://github.com/pray3m/JavaPrograms/blob/main/LAB4/BoxDemo.java)
20+
- [Q.N 10*](https://github.com/pray3m/JavaPrograms/blob/main/LAB4/BoxDemo.java)
21+
- [Q.N 11*](https://github.com/pray3m/JavaPrograms/blob/main/LAB4/BoxDemo.java)
22+
- [Q.N 12*](https://github.com/pray3m/JavaPrograms/blob/main/LAB4/BoxDemo.java)
23+

LAB4/SimpleInheritance.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* 1. Demonstrate the feature of simple inheritance */
2+
3+
/*
4+
* author : @pray3m
5+
*/
6+
7+
class Animal{
8+
void eat(){
9+
System.out.println("I can eat.");
10+
}
11+
12+
void sleep(){
13+
System.out.println("I can sleep.");
14+
}
15+
}
16+
17+
class Dog extends Animal{
18+
void bark(){
19+
System.out.println("I can Bark.");
20+
}
21+
}
22+
23+
public class SimpleInheritance {
24+
public static void main(String[] args) {
25+
Dog d1=new Dog();
26+
d1.eat();
27+
d1.sleep();
28+
d1.bark();
29+
}
30+
}

LAB4/lab 4(Inheritance).pdf

136 KB
Binary file not shown.

0 commit comments

Comments
 (0)