Method overriding in java

488 views

Published on

WAP on method overriding in java

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
488
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Method overriding in java

  1. 1. //Ques. 13 WAP on method overriding . class wallet { double dim1,dim2; wallet(double a, double b) { dim1=a; dim2=b; } double salary() { System.out.print("n Income for Lifetime is Not Calculated = "); return 0; } } class monthly extends wallet { monthly(double a, double b) { super(a,b); } double salary() { System.out.print("n Monthly income is = "); return dim1*dim2; } }
  2. 2. class annual extends wallet { annual(double a, double b) { super(a,b); } double salary() { System.out.print("n Annual income is = "); return dim1*dim2; } } class salary { public static void main(String arr[]) { wallet d = new wallet(10,10); monthly m = new monthly(330,30); annual a = new annual(10000,12); walletuv; uv = m; System.out.print(+uv.salary()); uv = a; System.out.print(+uv.salary()); uv = d; System.out.print(+uv.salary()+"n"); } }
  3. 3. OUTPUT:-

×