Skip to content

Commit cb932bf

Browse files
committed
Inheritance classes added
1 parent fc38c33 commit cb932bf

File tree

4 files changed

+81
-0
lines changed

4 files changed

+81
-0
lines changed
1.26 KB
Binary file not shown.
652 Bytes
Binary file not shown.
736 Bytes
Binary file not shown.
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package com.concepts._01oops;
2+
3+
public class ClassInheritance
4+
{
5+
public static void main(String[] args)
6+
{
7+
FeaturePhone fp = new SmartPhone();
8+
9+
fp.func();
10+
System.out.println(fp.mobile);
11+
System.out.println(fp.mobilePrice);
12+
13+
fp.mobile = "Micromax A1";
14+
fp.mobilePrice = 1999;
15+
16+
System.out.println(fp.mobile);
17+
System.out.println(fp.mobilePrice);
18+
19+
SmartPhone sp = new SmartPhone();
20+
21+
System.out.println();
22+
sp.foo();
23+
sp.func();
24+
System.out.println(sp.mobile);
25+
System.out.println(sp.mobilePrice);
26+
System.out.println(sp.generation);
27+
System.out.println(sp.os);
28+
29+
sp.generation=20;
30+
sp.mobile="Lawa Bomb";
31+
sp.mobilePrice=799;
32+
sp.os="Android";
33+
34+
System.out.println();
35+
sp.foo();
36+
sp.func();
37+
System.out.println(sp.mobile);
38+
System.out.println(sp.mobilePrice);
39+
System.out.println(sp.generation);
40+
System.out.println(sp.os);
41+
42+
}
43+
}
44+
45+
class FeaturePhone
46+
{
47+
int mobilePrice;
48+
String mobile;
49+
50+
FeaturePhone()
51+
{
52+
mobilePrice = 1000;
53+
mobile = "Nokia 1100";
54+
}
55+
56+
public void func()
57+
{
58+
System.out.println("In Func");
59+
}
60+
}
61+
62+
class SmartPhone extends FeaturePhone
63+
{
64+
int generation;
65+
String os;
66+
67+
SmartPhone()
68+
{
69+
mobilePrice = 5000;
70+
mobile = "New Nokia 1100";
71+
72+
generation = 8;
73+
os = "iOS 8";
74+
75+
}
76+
77+
void foo()
78+
{
79+
System.out.println("In Foo");
80+
}
81+
}

0 commit comments

Comments
 (0)