Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 30bafa3

Browse files
inheritance program added
1 parent d9b52f6 commit 30bafa3

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

‎11_OOPs/OOPs3/Intro/Inheritanceone.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
public class Inheritanceone {
2+
double l;
3+
double w;
4+
double h;
5+
6+
Inheritanceone() {
7+
this.l = -1;
8+
this.w = -1;
9+
this.h = -1;
10+
// Default Constructor
11+
}
12+
13+
Inheritanceone(double side) {
14+
this.l = side;
15+
this.w = side;
16+
this.h = side;
17+
// Parameterized Constructor
18+
}
19+
20+
public Inheritanceone(double l, double w, double h) {
21+
this.l = l;
22+
this.w = w;
23+
this.h = h;
24+
// Passing all three arguments
25+
}
26+
27+
Inheritanceone(Inheritanceone old) {
28+
this.l = old.l;
29+
this.w = old.w;
30+
this.h = old.h;
31+
// Copy Constructor
32+
}
33+
34+
public void Information() {
35+
System.out.println("Running the Box");
36+
}
37+
38+
}
39+
40+
// Inheritance, simply defines, inheriting or deriving properties from the parent class by the child class.
41+
// Any class derived from the base class is the child class.
42+
// Child class inherits properties(variables, methods etc.) from the baseclass.
43+
// 'extends' keyword is the bridge b/w base class and the child class
44+
// Now, the child class has all the properties of the base class + properties of thier own.
45+
// When defining the constructor, you also need to initialize parent class variable also.
46+
47+
48+
49+
50+

‎11_OOPs/OOPs3/Intro/Inheritancetwo.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public class Inheritancetwo {
2+
3+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /