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
What is the output of the following code fragment?
Int i = 1;
Int sum = 0;
While (i <= 11)
{
Sum = sum + i;
I++;
}
System.out.println("The value of sum is " + sum);
(Multiple Choice)
4.8/5
(38)
How many times does the following code fragment display "Hi"?
Int i = 10;
While (i >= 0)
{
System.out.println("Hi");
I--;
}
(Multiple Choice)
4.9/5
(41)
What will be printed by the statements below?
Int a = 10;
While (a > 5)
{
A = a - 2;
System.out.print (a + " ");
}
(Multiple Choice)
4.9/5
(46)
What is the last output line of the code snippet given below?
Int i = 0;
While (i < 10)
{
Int num = 1;
For (int j = i; j > 1; j--)
{
System.out.print(j + " ");
Num = num * 2;
}
System.out.println("***");
I++;
}
(Multiple Choice)
4.9/5
(41)
What is the data type of the number generated by the Random.nextDouble() method?
(Multiple Choice)
4.8/5
(24)
What is the result when the following code is run? double x = 1;
Double y = 1;
Int i = 0;
Do
{
Y = x / 2;
X = x + y;
I = i + 1;
}
While (x < 2.5);
System.out.print(i + " ");
(Multiple Choice)
4.8/5
(28)
What is the output of the code snippet given below? String s = "abcde";
Int i = 1;
While (i < 5)
{
System.out.print);
I++;
}
(Multiple Choice)
4.8/5
(38)
When hand tracing, drawing a line through the value stored in a variable means that
(Multiple Choice)
4.9/5
(42)
What is the output of the code snippet given below? String s = "abcde";
Int i = 1;
Do
{
If (i > 1)
{
System.out.print);
}
}
While (i < 5);
(Multiple Choice)
4.7/5
(39)
Which of the following loops will print the odd numbers between 0 and 20?
(Multiple Choice)
4.7/5
(40)
What is the output of the code below? for (int val = 0; val < 4; val ++)
{
Int sum = val;
For (int num = 0; num < val; num++)
{
Sum = sum + num;
}
System.out.print (sum + " ");
}
(Multiple Choice)
4.8/5
(34)
What does the method below return?
Int findSomething (String str)
{
Int position = 0;
While (position < str.length() &&
(str.charAt (position) != 'e'))
{
Position++;
}
Return position;
}
(Multiple Choice)
4.7/5
(42)
Which of the following loops executes the statements inside the loop before checking the condition?
(Multiple Choice)
4.8/5
(40)
In the following code snippet, when does the execution of the program switch from the inner loop to the outer loop?
Int i;
Int j;
For (i = 0; i <= 9; i++)
{
For (j = 1; j < 5; j++)
{
System.out.println("Hello");
}
}
(Multiple Choice)
4.8/5
(36)
Which of the following code snippets will generate a random number between 0 (inclusive) and 79 (inclusive)? (Assume Random generator = new Random();)
(Multiple Choice)
4.9/5
(38)
Which of the following is the correct code snippet for throwing a pair of dice to get a sum of the numbers on two dice between 2 and 12 with different probabilities? (Assume Random generator = new Random();)
(Multiple Choice)
4.8/5
(43)
Which of the following code snippets displays the output exactly 10 times?
(Multiple Choice)
4.8/5
(37)
What is the output of the code snippet given below?
Int i = 0;
While (i != 11)
{
System.out.print(" " + i);
I = i + 2;
}
(Multiple Choice)
4.8/5
(38)
How many times does the loop execute in the following code fragment?
Int i;
For (i = 0; i < 50; i = i + 4)
{
System.out.println(i);
}
(Multiple Choice)
4.9/5
(38)
Showing 81 - 100 of 128
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)