//2. NEP Program to perform mathematical operations.
import java.io.*;
class
AddSub
{
static int num1=25, num2=5;
public static void add()
{
System.out.println("Sum="+(num1+num2));
}
public static void subtract()
{
System.out.println("Diff="+(num1-num2));
}
public static void main(String args[])
{
AddSub obj1=new AddSub();
MulDiv obj2=new MulDiv();
System.out.println("Mathematical
Operations:");
obj1.add();
obj1.subtract();
obj2.multiply();
obj2.divide();
}
}
class
MulDiv extends AddSub
{
public static void multiply()
{
System.out.println("Div="+(num1/num2));
}
public static void divide()
{
System.out.println("Prod="+(num1*num2));
}
}
No comments :
Post a Comment