Test
Java Week 2 Repetition
Crea una cuenta gratis para terminar este test
Guarda tu progreso y consulta tu resultado final.
¿Ya tienes cuenta? Inicia sesión
Preguntas del test (17)
1Which of the following statements about the 'block' statement are true
- Ait groups a sequence of statements into a single statement
- Bit conditionally executes a sequence of statements
- Cit is used to prevent a sequence of statements from being executed
- Dit is used to contain a main statement
2What output will the following code produce
int number;
number = 1;
while ( number < 6) {
System.out.print(number);
number += 1;
}- A12345
- B01234
- C123456
- D13579
3What is the following java code structure known as
for ( i=0; i<10; i++) {
for (j=0; j<10; j++) {
//do something
}
}- Anested loop
- Bdouble loop
- Cexponential loop
- Dnone of the above
4Which best describes the code below:
while ( true ) {
System.out.print("loop again)'
}- Ait is an infinite loop that will continue to loop forever (until the program is terminated)
- Bit is an interative loop that ends when the conditional expression is false
- Cit is not valid java code
- Dnone of the above
5What will be the output of the code below:
int number;
number = 1;
while ( number < 6 ) {
System.out.print (number);
number = number + 1;
}
System.out.print("Done!");- A1
2
3
4
5
Done! - B12345Done!
- C12345
- D12345
Done!
- A1
6What will be the output of the code below:
String x = stringFunction("mississippi");
static String stringFunction(String str) {
String test;
int i;
test = "";
for (i = str.length() - 1; i >+ 0; i--) {
test = test + str.charAt(i);
}
return (test);
}- Amississippi
- Bm i s s i s s i p p i
- Cippississim
- Dnull string
7An "animation" consists of a sequence of images shown rapidly one after the other on the computer screen.
Each image i the animation is called a "frame".
Suppose that you have a subroutine
static void showFrame(int frameNum)
that displays one frame in an animation
That is, showFrame(1) display the first name showFrame(2) displays the second frame, and so on.
Suppose that there are a total of thirty different frames.
How many frames will the following code display?
for ( in play = 0; play < 10; play ++) {
for ( int i = 1; i < =30; i++)
showFrame(i);
}- A30 frames repeated 10 times
- B310 frames
- C10 frames
- D30 frames
8A for loop can use a list structure such as an enum to iterate the for loop?
- AVerdadero
- BFalso
9The break loop when encountered will cause processing to skip to the beginning of the loop?
- AVerdadero
- BFalso
10The continue statement when used in a loop will cause the flow of process to skip to the end of the loop and begin another iteration of processing?
- AVerdadero
- BFalso
11A for loop is used when the number of iterations through the loop is known in advance?
- AVerdadero
- BFalso
12The while loop is used when a known, finite number of loop iterations is required.
- AVerdadero
- BFalso
13The conditional expression in a while loop can be any expression that evaluates to a logical True or False?
- AVerdadero
- BFalso
14The while loops repeats a set of code while the condition is false.
- AVerdadero
- BFalso
15The do-while loop repeats a set of code at least once before the condition is tested.
- AVerdadero
- BFalso
16The for loop repeats a set of statements a certain number of times until a condition is matched.
- AVerdadero
- BFalso
17Can a for statement loop indefinitely?
- AVerdadero
- BFalso
Información
- Descripción
- AS - Level (CS1102 Java) Computer Science Test sobre Java Week 2 Repetition, creado por Troy Bowlin el 02/10/2016.
- Autor
- Troy Bowlin
- Idioma
- English
- Visitas
- 0
- Etiquetas
- Valoración
- Aún sin valoraciones Valora este test