IS5103 WEEK-2 QUIZE’S

Q1. How many times will the following code print “Welcome to Java”?

int count = 0;

do {

System.out.println(“Welcome to Java”);

} while (count++ < 10);

11

Q2. Which of the following is the correct expression that evaluates to true if the number x is between 1 and 100 or the number is negative?

((x < 100) && (x > 1)) || (x < 0)

Q3. In Java, the symbol “=” and the symbol “==” are used synonymously (interchangeably).

FALS

Q4. What is the output for y?


int y = 0;
for (int i = 0; i &lt; 10; ++i) {
y += i;
}
System.out.println(y);

 45

Q5. Assume that x and y are int variables with x = 5, y = 3, and a and d are char variables with a = ‘a’ and d = ‘A’, and examine the following conditions:

Condition 1: (x < y && x > 0)
Condition 2: (a != d || x != 5)
Condition 3: !(true && false)
Condition 4: (x > y || a == ‘A’ || d != ‘A’)

Conditions 2, 3 and 4 are all true, Condition 1 is not

Q6. The following loop is syntactically valid.

for (int j = 0; j < 1000; j++) j–;

TRUE

Q7. The statement if (a >= b) a++; else b–; will do the same thing as the statement if (a < b) b–; else a++;.

TRUE

Q8. The do loop differs from the while loop in that

 the do loop will always execute the body of the loop at least once

Q9. An if statement may or may not have an else clause, but an else clause must be part of an if statement.

TRUE

Q10. Which of the following statements are true about Java loops?

 all three loop statements are functionally equivalent

Other Links:

Statistics Quiz

Networking Quiz

See other websites for quiz:

Check on QUIZLET

Check on CHEGG

Leave a Reply

Your email address will not be published. Required fields are marked *