1.What is the output of the code snippet given below? Select one: a. No output b
ID: 3679968 • Letter: 1
Question
1.What is the output of the code snippet given below?
Select one:
a. No output
b. 0 3 6 9 12 15 18
c. 0 1 3 5 7 9
d. 0 3 6 9 …. (infinite loop)
2.
What is the output of the following code snippet?
Select one:
a. 0 1 5 7 9 11 13 15 17 19
b. 0 1 1 2 3 5 8 13 21 34
c. 0 1 4 6 8 10 12 14 16 18
d. 0 1 6 7 9 12 14 17 19 21
3.
Which of the following is considered a loop with a bound that could be problematic?
Select one:
a. for (i = 1; i != n; i++)
b. for (years = n; years < 0; years--)
c. for (i = 1; i <= n; i++)
d. for (int i = 1; i <= 10; i++)
4.
Which of the following is correct for simulating the toss of a pair of coins to get 0 (head) or 1 (tail) with different probabilities?
Select one:
a. (int) (Math.random() * 0 + 1)
b. (int) (Math.random() * 1 + 1)
c. (int) (Math.random() * 2)
d. (int) (Math.random() * 2) + (int) (Math.random() * 2)
5.
What is the output of the following code snippet?
Select one:
a. 16.0
b. 128.0
c. 4096.0
d. 65536.0
Explanation / Answer
Answer 1 :- Option d. 0 2 4 6 8 10 12 14 .... (infinite loop)code.
Answer 2 :- Option b. 0 1 1 2 3 5 8 13 21 34
Answer 3 :- Option a. for (i = 1; i != n; i++)
Answer 4 :- Option d. (int) (Math.random() 2) + (int) (Math.random() 2)
Answer 5 :- Option d. 65536.0
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.