-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQue-26.java
More file actions
28 lines (28 loc) · 889 Bytes
/
Copy pathQue-26.java
File metadata and controls
28 lines (28 loc) · 889 Bytes
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
//WAP to demonstrate java inheritance. Write two classes namely calculation and My_calculation. Using extends keyword, the My_calculation inherits the methods addition() and subtraction() of calculation class. My_calculation.java has its own method multiplication.
//By: Parth Panjwani
class Calculation
{
public int addition(int a, int b)
{
return a+b;
}
public int subtraction(int a, int b)
{
return a-b;
}
}
class My_calculation extends Calculation
{
public int multiplication(int a, int b)
{
return a*b;
}
}
class Que26 {
public static void main(String[] args) {
My_calculation mc = new My_calculation();
System.out.println("Addition: "+mc.addition(10,20));
System.out.println("Subtraction: "+mc.subtraction(20,10));
System.out.println("Multiplication: "+mc.multiplication(10,20));
}
}