Computer Applications
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
User Defined Methods
ICSE Sp 2025
2 Likes
Answer
Assertion (A) is true and Reason (R) is false
Explanation — Arguments are the actual values passed to a method when it is invoked. For example:
void exampleMethod(int x) { ... }
exampleMethod(5); // Here, 5 is the argument.
Hence, Assertion (A) is true.
The variables declared in a method prototype (or header) to receive values are called formal parameters, not actual parameters. For example:
void exampleMethod(int x) { // x is the formal parameter
System.out.println(x);
}
exampleMethod(5); // 5 is the actual parameter
Hence, Reason (R) is false.
Answered By
2 Likes
Related Questions
The statement used to find the total number of Strings present in the string array String s[] is:
- s.length
- s.length()
- length(s)
- len(s)
Consider the following program segment in which the statements are jumbled, choose the correct order of statements to swap two variables using the third variable.
void swap(int a, int b) { a = b; → (1) b = t; → (2) int t = 0; → (3) t = a; → (4) }
- (1) (2) (3) (4)
- (3) (4) (1) (2)
- (1) (3) (4) (2)
- (2) (1) (4) (3)
Rewrite the following code using single if statement.
if(code=='g') System.out.println("GREEN"); else if(code=='G') System.out.println("GREEN");
Evaluate the given expression when the value of a=2 and b=3
b*=a++ - ++b + ++a; System.out.println("a= "+a); System.out.println("b= "+b);