Java Test 36) What is the number of iterations in the following loop: for (int i
ID: 3819932 • Letter: J
Question
Java Test
36) What is the number of iterations in the following loop: for (int i = 1; i < = n; i++) { // iteration }
36) A) n B) n + 1 C) n - 1 D) 2*n
37) What is Math.rint(3.6)?
37) A) 4.0 B) 3.0 C) 5.0 D) 3 7
38) What code may be filled in the blank without causing syntax or runtime errors: public class Test { java.util.Date date; public static void main(String[ ] args) { Test test = new Test(); System.out.println(________); } }
38) A) test.date B) date.toString() C) test.date.toString() D) date
39) Suppose x=10 and y=10 what is x after evaluating the expression (y >= 10) || (x- - > 10)?
39) A) 11 B) 9 C) 10
40) What is the value in count after the following loop is executed? int count = 0; do { System.out.println("Welcome to Java"); } while (count++ < 9); System.out.println(count); 40) A) 8 B) 0 C) 9 D) 10 E) 11
Explanation / Answer
Answer36:(A)
for (int i = 1; i <= n; i++) {
// iteration
}
there will be n iteration because the conditon define in loop is <=n so it will run n times giving you n iterations.
---------------------------------------------------------------
Answer37:(A)
4.0 becuse it the function of maths we are calling will round of the value provided to it.
--------------------------------------------------------
Answer38:(A)
test.date satisfy the condtion given it will run the code without any run time error or syntax error
--------------------------------------------------------
Answer39:(C)
because after evaluting the condition first case of the codtion will be truwe and it will pass on we are using or operator (||) here so the value of X will not be changed.
------------------------------------------------------------
Answer40:(D)
it will print the text message 10times because we use ++ condtion so it will lead it to print 10times.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.