Answer to Question #268225 in Java | JSP | JSF for candy

Question #268225

1. Consider the following program, what is the output? (5 marks)

class overload

{

int x;

double y;

void add(int a , int b)

{ x = a + b; }

void add(double c , double d)

{ y = c + d; } overload()

{ this.x = 0;

this.y = 0;

}

} class Overload_methods

{ public static void main(String args[])

{

overload obj = new overload();

int a = 2; double b = 3.2;

obj.add(a, a);

obj.add(b, b);

System.out.println(obj.x + " " + obj.y); 


1
Expert's answer
2021-11-24T14:12:10-0500


SOLUTION

The following is the output of the program:
4 6.4

Explanation
This is beacuse x is the sum of the two integers and it is given integer 2 i.e 2+2 = 4
y is the sum of two double vlaues and it is given 3.2 i.e 3.2 + 3.2 = 6.4

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS