1. int x; x = (7 <= 6 && \'A\' < \'F\') ? 4 : 3 Based on the code, what is the v
ID: 3575962 • Letter: 1
Question
1. int x; x = (7 <= 6 && 'A' < 'F') ? 4 : 3
Based on the code, what is the value of x?
2. Which of the following is true about a while loop?
A. It it a post test loop.
B. The body of the loop is executed at least once.
C. The logical expression controlling the loop is evaluated before the loop is entered and after the loop exists.
D. None of these
3. The = operator is used to assign a value to a variable. True or False
4. what is the output of the Java code below
int i;
for (i = 1; i <= 15; i++);
System.out.print(i + " ");
Explanation / Answer
1. Based on code, value of x is 3 as the condition before '?' evaluates to false.
2. C is true. While is a pre-test loop. The condition gets checked before loop body is executed, and also after the loop body is executed, to check whether next iteration should take place or not.
3. True, = is used for assignment, and == for comparison.
4. Output would be: 16
The loop is an empty loop and it terminates when the condition "i<=15" evaluates to false, and that is when i=16.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.