Computer Applications
Rewrite the following program segment using a for loop.
int a = 5, b = 10;
while (b > 0)
{ b -= 2;
}
System.out.println(a * b);
Java Iterative Stmts
3 Likes
Answer
int a = 5, b = 10;
for( ; b > 0; b -= 2)
{
}
System.out.println(a * b);
Answered By
2 Likes
Related Questions
Assertion (A): The substring() method modifies the original String.
Reason (R): The substring() method can extract part of a String starting from a specific index.
- (A) is true and (R) is false.
- (A) is false and (R) is true.
- Both (A) and (R) are true and (R) is a correct explanation of (A).
- Both (A) and (R) are true and (R) is not a correct explanation of (A).
In constructor overloading, all constructors should have the the same name as of the class but with a different set of …………… .
- Access specifiers
- Classes
- Return type
- Parameters
Evaluate the Java expression:
x = a * b % (++c) + (++a) + (--b);if a = 7, b = 8, c = 2
Write the Java expression to find the sum of cube root of x and the absolute value of y.