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

Question #282065

 Consider the following program, what is the output? (2 marks)

 class overload

 {

 int x;

 double y;

 void prod(int n)

 {

 for (int i=1;i<n;i++)

 x=x*i

 }

 void prod(int n, int m)

 {

 for (int i=n;i<m;i++)

 y=y*i

 }

 overload()

 {

 this.x = 1;

 this.y = 1;

 }


}

 class Overload_methods

 {

 public static void main(String args[])

 {

 overload obj = new overload();

 int n = 2;

 int m = 4;

 obj.prod(n);

 obj.prod(n,m);

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

 }

 }


1
Expert's answer
2021-12-24T13:48:32-0500

output is: 1 6


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