-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1174 from MacTavish-exe/patch-3
Create SuperClass.java
- Loading branch information
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
Program's_Contributed_By_Contributors/Java_Programs/Misc/SuperClass.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
class Super | ||
{ | ||
int x; | ||
Super(int x) | ||
{ | ||
this.x = x; | ||
} | ||
void display() | ||
{ | ||
System.out.println("Super x =" +x); | ||
} | ||
} | ||
Class Sub extends Super | ||
{ | ||
int y; | ||
sub (int x, int y) | ||
{ | ||
super (x); | ||
this.y=y; | ||
} | ||
void display() | ||
{ | ||
System.out.println("Super x =" +x); | ||
System.out.println("Sub y =" +y); | ||
} | ||
} | ||
class OverrideTest | ||
{ | ||
public static void main(String args[]) | ||
{ | ||
Sub sl = new Sub(100,200); | ||
sl.display(); | ||
} | ||
} |