Question
Java MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question 15) What is sum after the following loop terminates?
Java
MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question
15) What is sum after the following loop terminates? int sum = 0; int item= 0; do { item++; sum += item; if (sum > 4) break; } while (item < 5); 15) A) 6 B) 8 C) 7 D) 5 16) Do the following two statements in (I) and (II) result in the same value in sum? (I): for (int i= 0; i<10; ++i) { sum += i; } (II): for (int i= 0; i<10; i++) { sum += i; } 16) A) Yes B) No 17) How many times will the following code print "Welcome to Java"? int count= 0; while (count++ < 10) { System.out.println("Welcome to Java"); } 17) A) 9 B) 10 C) 8 D) 11 E) 0 18) To declare an int variable number with initial value 2, you write 18) A) int number= 2.0; B) int number= 2L; C) int number= 2l; D) int number= 2; 3 19) What is y displayed? public class Test { public static void main(String[ ] args) { int x= 1; int y= x+ x++; System.out.println("y is "+ y); } } 19) A) y is 3. B) y is 4. C) y is 2. D) y is 1.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started