CS1102 Unit 8 Quiz UotP

¡Supera tus tareas y exámenes ahora con Quizwiz!

Consider the following block of Java code. How many times will it output "Hello"? for (int i = 1; i < 10; i++) { System.out.println("Hello"); }

9

Consider the following Java program, what starts on line 2? 1 public class HelloWorld { 2 // My first program! 3 public static void main(String[] args) { 4 System.out.println("Hello, World!"); 5 } 6 }

a comment

Consider the following line of Java code. System.out.println("Hello, World!"); "println" is which of the following?

a method (subroutine)

Which of the following can a class NOT be used for?

a primitive type

Consider the following Java program, what starts on line 4? 1 public class HelloWorld { 2 // My first program! 3 public static void main(String[] args) { 4 System.out.println("Hello, World!"); 5 } 6 }

a statement

Consider the following line of Java code. System.out.println("Hello, World!"); The full line of code is which of the following?

a statement

Which of the following is NOT a valid identifier in Java?

public

Consider the following Java statements.int x = 3; x = x++; What is the value of x after these statements are executed?

3

In a while loop, how many times does the continuation condition run?

At least once, at the beginning of each iteration.

In a for loop, how many times does the continuation condition run?

At least once, at the beginning of each iteration.

Consider the following class definition. Which variables can be used in the missing "println" expression on line 12? 1 public class PrintStuff 2 { 3 public static void main() 4 { 5 6 { 7 int i = -1; 8 System.out.println(_____); 9 } 10 int j = 1; 11 for (j = 0; j < 10; j++) { 12 System.out.println(_____); 13 } 14 { 15 int k; 16 for (k = 0; k < 10; k++) { 17 System.out.println(_____); 18 } 19 } 20 System.out.println(_____); 21 } 22 }

Only "j"

Consider the following class definition. Which variables can be used in the missing "println" expression on line 20? 1 public class PrintStuff 2 { 3 public static void main() 4 { 5 6 { 7 int i = -1; 8 System.out.println(_____); 9 } 10 int j = 1; 11 for (j = 0; j < 10; j++) { 12 System.out.println(_____); 13 } 14 { 15 int k; 16 for (k = 0; k < 10; k++) { 17 System.out.println(_____); 18 } 19 } 20 System.out.println(_____); 21 } 22 }

Only "j"

Which one of the following types are not allowed for the expression in a switch statement?

float

Which of the following keywords is useful for loops that should always execute at least once?

do

Consider the following Java declaration and assignment statement. float x = y; Which one of the following types is "y" NOT allowed to be?

double

Which one of the following is used in Java programming to handle asynchronous events?

event handlers

Which of the following keywords is useful for processing lists of menu options?

switch

Assume "test" is a boolean variable. Which of the following expressions is equivalent to "test == true"?

test


Conjuntos de estudio relacionados

Definitions (Weeks 6 & 7) Statistics

View Set

Chapter 16: Breach of Contract and Remedies

View Set