0% found this document useful (0 votes)
16 views1 page

Test

The document defines a Java class with a constructor that takes two integer parameters and assigns them to instance variables, and two methods - one to print the sum of the instance variables and one to print the difference.

Uploaded by

Test
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views1 page

Test

The document defines a Java class with a constructor that takes two integer parameters and assigns them to instance variables, and two methods - one to print the sum of the instance variables and one to print the difference.

Uploaded by

Test
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

package javaapplication5;

import java.util.Scanner;

public class JavaApplication5 {


int a,b,c=0;
public JavaApplication5(int x,int y)

{
a=x;
b=y;
}
void sum( )
{
System.out.println("The sum is :"+(a+b));
}
void sub()
{
System.out.println("The sub is :"+(a-b));
}

public static void main(String[] args) {


int a,b;
String s;
Scanner userinput=new Scanner(System.in);
s=userinput.next();
a=Integer.parseInt(s);
s=userinput.next();
b=Integer.parseInt(s);
JavaApplication5 obj =new JavaApplication5(a,b);
obj.sum();
obj.sub();
}

You might also like