Computer Applications
What are the values of a and b after the following function is executed, if the values passed are 30 and 50:
void paws(int a, int b)
{
a=a+b;
b=a–b;
a=a–b;
System.out.println(a+ "," +b);
}
User Defined Methods
ICSE 2015
24 Likes
Answer
Value of a is 50 and b is 30.
Output of the code is:
50,30
Answered By
12 Likes
Related Questions
Assertion (A): An argument is a value that is passed to a method when it is called.
Reason (R): Variables which are declared in a method prototype to receive values are called actual parameters
- Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of Assertion (A)
- Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of Assertion(A)
- Assertion (A) is true and Reason (R) is false
- Assertion (A) is false and Reason (R) is true
Invoking a method by passing the objects of a class is termed as:
- Call by reference
- Call by value
- Call by method
- Call by constructor
Define a class to overload the method display() as follows:
void display(): To print the following format using nested loop.
1 2 1 2 1
1 2 1 2 1
1 2 1 2 1void display (int n, int m) : To print the quotient of the division of m and n if m is greater than n otherwise print the sum of twice n and thrice m.
double display (double a, double b, double c) — to print the value of z where