0% found this document useful (0 votes)
3 views3 pages

Multiplication Details

The Java code defines a class 'Multiply' with multiple constructors for multiplying different numbers of integers. It includes a default constructor that multiplies two hardcoded values and three overloaded constructors for multiplying two, three, and four integers, respectively. The main method demonstrates the usage of these constructors and prints the results of the multiplications.

Uploaded by

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

Multiplication Details

The Java code defines a class 'Multiply' with multiple constructors for multiplying different numbers of integers. It includes a default constructor that multiplies two hardcoded values and three overloaded constructors for multiplying two, three, and four integers, respectively. The main method demonstrates the usage of these constructors and prints the results of the multiplications.

Uploaded by

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

Java Code for Multiply Class

class Multiply {
int a;
int b;
int c;
int d;
Multiply() {
int a = 2;
int b = 4;
System.out.println("Multiplication of 2 no's = " +(a * b));
}
Multiply(int p, int q) {
a = p;
b = q;
int result = a*b;
System.out.println("Multiplication of 2 no's = " +result);
}
Multiply(int p, int q, int r) {
a = p;
b = q;
c = r;
int result = a*b*c;
System.out.println("Multiplication of 3 no's = " +result);
}
Multiply(int p, int q, int r, int s) {
a = p;
b = q;
c = r;
d = s;
int result = a*b*c*d;
System.out.println("Multiplication of 4 no's = " +result);
}
public static void main(String[] args) {
Multiply m1 = new Multiply();
Multiply m2 = new Multiply(58, 99);
Multiply m3 = new Multiply(58, 99, 44);
Multiply m4 = new Multiply(58, 99, 44, 55);
}
}
<<<<<<<<<<<<<<<<<<<<<Output>>>>>>>>>>>>>>>>>>>>>
Multiplication of 2 numbers: 5742
Multiplication of 3 numbers: 252648
Multiplication of 4 numbers: 13895640

You might also like