X will complete the code to calculate c = a2 + b2 + 2ab ? public class MyCalc { public int powerSq(int num) { return num * num; } public int mult(int a, int b) { return a * b; } public static void main(String [] args) { int a = 1; int b = 2; int c; MyCalc myCalc = new MyCalc(); XXX } } answers: 1) c = powerSq(a) + powerSq(b) + 2 * mult(a); 2) c = powerSq(a, b) + powerSq(a, b) + 2 * mult(a, b); 3) c = myCalc.powerSq(a) + myCalc.powerSq(b) + 2 * myCalc.mult(a); 4) c = myCalc.powerSq(a) + myCalc.powerSq(b) + 2 * myCalc.mult(a, b)
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Which XXX will complete the code to calculate c = a2 + b2 + 2ab ?
public class MyCalc {
public int powerSq(int num) {
return num * num;
}
public int mult(int a, int b) {
return a * b;
}
public static void main(String [] args) {
int a = 1;
int b = 2;
int c;
MyCalc myCalc = new MyCalc();
XXX
}
}
answers:
Trending now
This is a popular solution!
Step by step
Solved in 2 steps