Exam 6: Loops
Exam 1: Introduction98 Questions
Exam 2: Using Objects76 Questions
Exam 3: Implementing Classes103 Questions
Exam 4: Fundamental Data Types125 Questions
Exam 5: Decisions120 Questions
Exam 6: Loops128 Questions
Exam 7: Arrays and Array Lists118 Questions
Exam 8: Designing Classes95 Questions
Exam 9: Inheritance101 Questions
Exam 10: Interfaces85 Questions
Exam 11: Inputoutput and Exception Handling109 Questions
Exam 12: Object-Oriented Design104 Questions
Exam 13: Recursion110 Questions
Exam 14: Sorting and Searching109 Questions
Exam 15: The Java Collections Framework110 Questions
Exam 16: Basic Data Structures104 Questions
Exam 17: Tree Structures110 Questions
Exam 18: Generic Classes75 Questions
Exam 19: Graphical User Interfaces76 Questions
Exam 20: Streams and Binary Inputoutput82 Questions
Exam 21: Multithreading82 Questions
Exam 22: Internet Networking74 Questions
Exam 23: Relational Databases75 Questions
Exam 24: XML74 Questions
Exam 25: Web Applications75 Questions
Select questions type
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;
}
}
(Multiple Choice)
4.8/5
(37)
When designing storyboards, it is a good idea to use different colors to
(Multiple Choice)
4.8/5
(35)
What for loop can be used in the indicated area so the code will print: ****
***
**
*
For (int val = 0; val < 4; val ++)
{
System.out.print ("+");
// Put for loop here
{
System.out.print ("*");
}
System.out.println ();
}
(Multiple Choice)
5.0/5
(41)
When hand-tracing the loop in the code snippet below, which variables are important to evaluate?
Int i = 10;
Int j = 5;
Int k = -10;
Int sum = 0;
While (i > 0)
{
Sum = sum + i + j;
I--;
System.out.println("Iteration: " + i);
}
(Multiple Choice)
4.9/5
(33)
For which input values will the following loop not correctly compute the maximum of the values? Scanner in = new Scanner (System.in);
Int max = 0;
While (in.hasNextInt())
{
Int value = in.nextInt();
If (value > max)
{
Max = value;
}
}
(Multiple Choice)
4.9/5
(34)
What is the output of the following code snippet?
Int f1 = 0;
Int f2 = 1;
Int fRes;
System.out.print(f1 + " ");
System.out.print(f2 + " ");
For (int i = 1; i < 10; i++)
{
FRes = f1 + f2;
System.out.print(fRes + " ");
F1 = f2;
F2 = fRes;
}
System.out.println();
(Multiple Choice)
4.8/5
(44)
What is the output of the code snippet given below? String s = "aeiou";
Int i = 0;
Do
{
System.out.print);
I++;
If (i >= 3)
{
I = 5;
}
}
While (i < 5);
(Multiple Choice)
4.7/5
(42)
What is the output of the following code snippet?
Int i = 1;
While (i < 20)
{
System.out.print(i + " ");
I = i + 2;
If (i == 15)
{
I = 19;
}
}
(Multiple Choice)
4.9/5
(36)
Suppose that a program asks a user to enter multiple integers, either positive or negative, to do some calculation. The data entry will stop when the user enters a certain value to indicate the end of the data. What value should the code use as the sentinel?
(Multiple Choice)
4.9/5
(36)
What is the output of this code snippet?
Int s = 1;
Int n = 1;
Do
{
S = s + n;
System.out.print(s + " ");
N++;
}
While (s < 3 * n);
(Multiple Choice)
4.8/5
(31)
What changes do you need to make in the following code snippet to display "Let us learn Java" exactly 10 times?
Int i = 0;
While (i <= 10)
{
System.out.println("Let us learn Java");
I++;
}
(Multiple Choice)
4.8/5
(34)
What is the output of the following loop?
Int s = 1;
Int n = 1;
Do
{
S = s + n;
N++;
}
While (s < 10 * n);
System.out.println(s);
(Multiple Choice)
4.8/5
(39)
Which statement is correct about the execution of the loop in the following code fragment? double num;
Int incr = 0;
Scanner reader = new Scanner(System.in);
Do
{
Incr = incr + 1;
System.out.println("Please enter a number (0 when done): ");
Num = reader.nextDouble();
}
While (num != 0);
System.out.println("" + incr);
(Multiple Choice)
4.8/5
(46)
How many times does the following loop execute? for (double d = 1; d != 10; d++)
{
D = d / 3;
System.out.print(d + " ");
}
(Multiple Choice)
4.9/5
(34)
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);
(Multiple Choice)
4.8/5
(31)
What will be the output of the following code snippet? boolean token = false;
While (token)
{
System.out.println("Hello");
}
(Multiple Choice)
4.8/5
(39)
What is the output of the following code snippet?
Int i = 1;
While (i <= 10)
{
System.out.println("Inside the while loop");
I = i + 10;
}
(Multiple Choice)
4.9/5
(35)
How many times does the code snippet given below display "Loop Execution"?
Int i = 1;
While (i != 10)
{
System.out.println ("Loop Execution");
I++;
}
(Multiple Choice)
4.8/5
(38)
What values does counter variable i assume when this loop executes? for (int i = 20; i >= 2; i = i - 6)
{
System.out.print(i + ",");
}
(Multiple Choice)
4.9/5
(28)
Showing 61 - 80 of 128
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)