OOP LAB 3 JAVA Intro

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

oop

//Main class
/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package testapp1;

/**
*

* @author PC

*/

public class Testapp1 {

private static Object obj1;

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

CalculatorImp obj1 = new CalculatorImp();

int a = obj1.add(5,6);

int b = obj1.mul(6,7);

System.out.println("Addition = "+a);

System.out.println("Multiplication = "+b);

CalculatorImp obj2 = new CalculatorImp();

int c = obj2.sub(7,3);

int d = obj2.div(15,2);

System.out.println("Subtraction = "+c);

System.out.println("Division = "+d);

//CalculatorImp
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package testapp1;

/**
*
* @author PC
*/
public class CalculatorImp implements Calculatorinf
{
public int add (int a, int b){
return (a+b);}
public int mul (int a, int b){
return (a*b);
}
public int sub (int a, int b){
return(a-b);
}
public int div (int a, int b){
return (a/b);
}
}

//CalculatorInf class name


/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package testapp1;

/**
*
* @author PC
*/
public interface CalcutorInf {
int add(int a, int b);
int multiply(int a, int b);
}
Output:

You might also like