-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstructorbasic.java
More file actions
41 lines (23 loc) · 975 Bytes
/
constructorbasic.java
File metadata and controls
41 lines (23 loc) · 975 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
29
30
31
32
33
34
35
36
37
38
39
40
41
public class constructorbasic {
int add; // always fix variable int or flote to use it any where in the class
int sub;
int mul;
int div;
public constructorbasic(int a, int b){
add = a +b; //no int for used up
sub = a -b;
mul = a *b;
div = a /b;
}
void display () {
System.out.println("The sum is :" + " " + add);
System.out.println("The sub is :" + " " + sub);
System.out.println("The mul is :" + " " + mul);
System.out.println("The div is :" + " " + div);
}
public static void main(String[]args) {
constructorbasic obj = new constructorbasic(5,5); // its passing value on the paramitter on line 9 as a constructor call and the value
// returend returend after all line executed on that constructor and stored in (obj)
obj.display(); // to show the value calling the display function
}
}