Q20. An else statement must be paired with an if statement. a. true b. false Q21
ID: 3887858 • Letter: Q
Question
Q20. An else statement must be paired with an if statement.
a. true
b. false
Q21. int x = 5;
int y = 30;
do
x = x * 2;
while(x < y);
How many times does the statement above execute?
a. 0
b. 1
c. 2
d. 3
Q22. int x = 5;
int y = 30;
do
x = x * 2;
while(x < y);
What is the final value of x in the code above?
a. 5
b. 10
c. 20
d. 40
Q23. The read method returns ____ when the end of the input file is reached.
a. null
b. -1
c. 0
d. 1
Q24. The read method returns the value null when trying to read past the end of the input file.
a. true
b. false
Explanation / Answer
--answer :
20)TRUE
with out else statement we can not write write the if statement with if statement not needed the else statement that is called a simple if
21)d,3times
that is the do while loop executes a first statement and then check the condition so that the above questions execute three times even though the last condition is failed respective statements of the loop is executed.
22)d,40
That is the condition is chitrapat three times the first time he is a value is 10 the second time is the value is 20 third time leave the value is 40 so the 40 is less than 30 that is y value so the loop is terminated so the final answer is 40.
23)b, - 1
The read method returns -1 when we reach reach at the end of the file in conserding language Java.
Each time read() is called, it reads a single byte from the file and returns the byte as an integer value. read() returns -1 when the end of the file is encountered
24)a, true
read method returns the value null when trying to read past the end of the input file.
The read method returns a value, null, which indicates that the end of the file has been reached
**feel free to ask queries if any**
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.