Exam 4: Loops
Exam 1: Introduction96 Questions
Exam 2: Fundamental Data Types103 Questions
Exam 3: Decisionseasy99 Questions
Exam 4: Loops100 Questions
Exam 5: Methods94 Questions
Exam 6: Arrays and Arraylists100 Questions
Exam 7: Inputoutput and Exception Handling100 Questions
Exam 8: Objects and Classes101 Questions
Exam 9: Inheritance and Interfaces99 Questions
Exam 10: Graphical User Interfaces54 Questions
Exam 11: Advanced User Interfaces91 Questions
Exam 12: Object-Oriented Design100 Questions
Exam 13: Recursion100 Questions
Exam 14: Sorting and Searching99 Questions
Exam 15: The Java Collections Framework100 Questions
Exam 16: Basic Data Structures94 Questions
Exam 17: Tree Structures100 Questions
Exam 18: Generic Classes78 Questions
Exam 19: Streams and Binary Inputoutput82 Questions
Exam 20: Multithreading82 Questions
Exam 21: Internet Networking74 Questions
Exam 22: Relational Databases75 Questions
Exam 23: XML74 Questions
Exam 24: Web Applications74 Questions
Select questions type
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
(38)
What is the output of the following code snippet?
Int i = 1;
While (i < 10)
{
System.out.print(i + " ");
I = i + 2;
If (i == 5)
{
I = 9;
}
}
(Multiple Choice)
4.8/5
(31)
What is the first and last value of i to be displayed by the following code snippet?
Int n = 20;
For (int i = 0; i <= n; i++)
{
For (int j = 0; j <= i; j++)
{
System.out.println("" + i);
}
}
(Multiple Choice)
4.8/5
(46)
Which for loop prints data across each row in the following code snippet?
Int i;
Int j;
For (i = 1; i <= 3; i++)
{
For (j = 1; j <= 3; j++)
{
System.out.print("X");
}
System.out.println("");
}
(Multiple Choice)
4.9/5
(35)
What is the output of the code snippet given below?
Int i = 0;
While (i != 11)
{
System.out.print(i + " ");
I = i + 3;
}
(Multiple Choice)
4.8/5
(36)
How many times does the following loop execute?
Int i = 0;
Boolean found = false;
While (i < 100 && !found)
{
i++;
System.out.print(i + " ");
int j = i * i;
if ((i * i * i) % j == j)
{
found = true;
}
}
(Multiple Choice)
4.9/5
(41)
How many times does the following code fragment display "Hi"?
Int i = 10;
While (i >= 0)
{
System.out.println("Hi");
I--;
}
(Multiple Choice)
4.8/5
(47)
What is the output of the code snippet given below?
String s = "12345";
Int i = 1;
Do
{
If (i > 1)
{
System.out.print);
}
}
While (i < 5);
(Multiple Choice)
4.8/5
(34)
What is the output of this loop?
int i = 0;
boolean found;
while (i < 20 && !found)
{
int sum = i * 2 + i * 3;
System.out.print(sum + " ");
if (sum > 50)
{
found = true;
}
i++;
}
(Multiple Choice)
4.9/5
(38)
Which of the loop(s) test the condition after the loop body executes?
I. for loop
II. while loop
III. do loop
(Multiple Choice)
4.9/5
(49)
What is the output of this code snippet?
String str = "ABCabc";
Char ch;
Int i = 0;
While (i < str.length())
{
Ch = str.charAt(i);
If (Character.isLowerCase(ch))
{
System.out.print(i + " ");
}
Else
{
I++;
}
}
(Multiple Choice)
4.7/5
(39)
How many times will the following loop run?
Int i = 0;
While (i < 10)
{
System.out.println(i);
I++;
}
(Multiple Choice)
4.8/5
(33)
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.8/5
(42)
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
(40)
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);
(Multiple Choice)
4.9/5
(35)
Which loop does not check a condition at the beginning of the loop?
I. The do loop
II. The while loop
III. The for loop
(Multiple Choice)
4.7/5
(30)
How many times does the following loop run?
Int i = 0;
Int j = 1;
Do
{
System.out.println("" + i + ";" + j);
I++;
If (i % 2 == 0)
{
J--;
}
}
While (j >= 1);
(Multiple Choice)
4.9/5
(39)
Which of the following loop(s) should be used when you need to ask a user to enter one data item and repeat the prompt if the data is invalid?
I. for loop
II. while loop
III. do loop
(Multiple Choice)
4.8/5
(40)
What will be the output of the following code snippet?
Boolean token1 = true;
While (token1)
{
For (int i = 0; i < 10; i++)
{
System.out.println("Hello");
}
Token1 = false;
}
(Multiple Choice)
4.8/5
(30)
What does the following code do?
Int sum = 0;
Final int count = 1000;
For (int i = 1; i <= count; i++)
{
Sum = sum + (int) (Math.random() * 101);
}
System.out.println(sum / count);
(Multiple Choice)
4.8/5
(37)
Showing 81 - 100 of 100
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)