-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDemo.java
50 lines (43 loc) · 1.14 KB
/
Demo.java
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class Maths
{
public int iNo1; //characteristcs
public int iNo2; //characteristcs
public Maths() // Default constructor
{
System.out.println("Inside default constructor");
iNo1 = 0;
iNo2 = 0;
}
public Maths(int a, int b) // Parametrised constructor
{
System.out.println("Inside paramtrised constructor");
iNo1 = a;
iNo2 = b;
}
public int Addition() // Behaviour
{
int iAns = 0;
iAns = iNo1 + iNo2;
return iAns;
}
public int Substraction() // Behaviour
{
int iAns = 0;
iAns = iNo1 - iNo2;
return iAns;
}
} //End of Maths class
class Demo
{
public static void main(String arr[])
{
System.out.println("Inside main function");
Maths mobj1 = new Maths();
Maths mobj2 = new Maths(10, 11);
int iRet = 0;
iRet = mobj1.Addition();
System.out.println("Addition is :"+iRet);
iRet = mobj2.Addition();
System.out.println("Addition is :"+iRet);
}
}