Services
Discover
Homeschooling
Ask a Question
Log in
Sign up
Filters
Done
Question type:
Essay
Multiple Choice
Short Answer
True False
Matching
Topic
Computing
Study Set
Big Java Binder Early Objects
Quiz 6: Loops
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 41
Multiple Choice
What does the method below return? Int findSomething (String str) { Int position = 0; While (position < str.length() && (str.charAt (position) != 'e') ) { Position++; } Return position; }
Question 42
Multiple Choice
Which of the following statements expresses why the following code is considered bad form? for (rate = 5; years-- > 0; System.out.println(balance) ) ) . . I. Unrelated expressions in loop header II. Doesn't match expected for loop idiom III. Loop iteration is not clear
Question 43
Multiple Choice
What does the following code snippet print? Int a = 120; Int b = 90; Int n1 = Math.abs(a) ; Int n2 = Math.abs(b) ; Int result = 1; For (int k = 1; k <= n1 && k <= n2; k++) { If (n1 % k == 0 && n2 % k == 0) { Result = k; } } System.out.println(result) ;
Question 44
Multiple Choice
What will be printed by the statements below? Int val = 1; Int sum = 0; While (val < 5) { Sum = sum + val; Val++; } System.out.print (sum) ;
Question 45
Multiple Choice
Which statement about this code snippet is accurate? Int years = 50; Double balance = 10000; Double targetBalance = 20000; Double rate = 3; For (int i = 1; i <= years; i++) { If (balance >= targetBalance) { I = years + 1; } Else { Double interest = balance * rate / 100; Balance = balance + interest; } }
Question 46
Multiple Choice
What is the output of the following code snippet? Int counter = 1; For (double i = 0.01; i <= 1.0; i = i + 0.01) { Counter++; } System.out.println(counter) ;
Question 47
Multiple Choice
What will be printed by the statements below? for (int ctr = 0; ctr < 10; ctr++) { System.out.print (ctr + " ") ; }
Question 48
Multiple Choice
Which of the following loops will print the odd numbers between 0 and 20?
Question 49
Multiple Choice
What will be printed by the statements below? Int val = 1; Int sum = 0; While (val < 5) { Sum = 0; Sum = sum + val; Val++; } System.out.print (sum) ;
Question 50
Multiple Choice
What will be printed by the statements below? Int a = 10; While (a > 5) { A = a - 2; System.out.print (a + " ") ; }
Question 51
Multiple Choice
What is the output of the code below? for (int val = 0; val < 4; val ++) { System.out.print ("+") ; For (int num = 0; num < val; num++) { System.out.print ("0") ; } }
Question 52
Multiple Choice
What does the following loop compute? Scanner in = new Scanner (System.in) ; Int sum = 0; Int count = 0; While (in.hasNextInt() ) { Int value = in.nextInt() ; If (value > 0) { Sum += value; Count++; } } Double result = (sum * 1.0) /count;