-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path14_Inheritance in java
81 lines (80 loc) · 1.46 KB
/
14_Inheritance in 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
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
//package com.company;
//
//class Animal{
// int a;
//
// public int getA() {
// return a;
// }
//
// public void setA(int a) {
// System.out.println("Speak");
// this.a = a;
// }
//}
//
//class Dog extends Animal{
// int C;
//
// public int getC() {
// System.out.println("Bark");
// return C;
// }
//
// public void setC(int c) {
// C = c;
// }
//}
//class Base{
// int x;
//
// public int getX() {
// return x;
// }
//
// public void setX(int x) {
// System.out.println("qwerty");
// this.x = x;
// }
//
// public void printMe(){
// System.out.println("Hello World");
// }
//}
//
//class Derived extends Base{
// int y;
//
// public int getY() {
// return y;
// }
//
// public void setY(int y) {
// this.y = y;
// }
//}
//public class Inheritance {
// public static void main(String[] args) {
//
// //Creating an object of base class
//
// Base b = new Base();
// b.setX(8);
// System.out.println(b.getX());
//
// // Creating an object of derived class
//
// Derived d = new Derived();
// d.setX(9);
// System.out.println(d.getX());
//
// Animal a = new Animal();
// a.setA(9);
// System.out.println(a.getA());
//
// Dog c = new Dog();
// c.setA(8);
// System.out.println(c.getA());
// System.out.println(c.getC());
// }
//}