Question: public class RandomCalculator { private int x; private int y; public RandomCalculator ( int one, int two ) { x = one; y = two;

public class RandomCalculator
{
private int x;
private int y;
public RandomCalculator(int one, int two)
{
x = one;
y = two;
}
public int add(int num)
{
return x + y + num;
}
public int add(double num)
{
return (int)(num)+ x / y;
}
public int add(double num, int num2)
{
return (int)(num2+ num + x - y);
}
public double add(int num, double num2)
{
return num + num2- x + y;
}
What would the output be of the following code segment:
RandomCalculator calc = new RandomCalculator(4,5);
System.out.println(calc.add(5.0));
System.out.println(calc.add(5.0,5));
System.out.println(calc.add(5,5.0));
Consider the following class:
public class RandomCalculator
{
private int x;
private int y;
public RandomCalculator(int one, int two)
{
x = one;
y = two;
}
public int add(int num)
{
return x + y + num;
}
public int add(double num)
{
return (int)(num)+ x / y;
}
public int add(double num, int num2)
{
return (int)(num2+ num + x - y);
}
public double add(int num, double num2)
{
return num + num2- x + y;
}
What would the output be of the following code segment:
RandomCalculator calc = new RandomCalculator(4,5);
System.out.println(calc.add(5.0));
System.out.println(calc.add(5.0,5));
System.out.println(calc.add(5,5.0));
5
9.0
11
14
9
11.0
14
11.0
9
5
9
11.0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!