GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

Assuming the variable n is an integer that stores a positive…

Assuming the variable n is an integer that stores a positive value, which of the following is a loop with a bound that could be problematic?

Read Details

How many times does the following code snippet display “Loop…

How many times does the following code snippet display “Loop Execution”? for (int i = 0; i < 10; i++); { System.out.println("Loop Execution"); }

Read Details

How many times does the following code fragment display “Hi”…

How many times does the following code fragment display “Hi”? int i = 10; while (i >= 0) { System.out.println(“Hi”); i–; }

Read Details

The code snippet below checks whether a given number is a pr…

The code snippet below checks whether a given number is a prime number. What will be the result of executing it? public static void main(String[] args) { int j = 2; int result = 0; int number = 0; Scanner reader = new Scanner(System.in); System.out.println(“Please enter a number greater than 1: “); number = reader.nextInt(); while (j

Read Details

The method below is designed to return the smaller of two Co…

The method below is designed to return the smaller of two Comparable objects received as arguments. Assume that the objects are instances of the same class. Select the correct expression to complete the method. public static Comparable smaller(Comparable value1, Comparable value2) { if (_________________________ ) return value1; else return value2); }

Read Details

Which of the following statements about constants in Java ar…

Which of the following statements about constants in Java are true? I.Although not required, constants are commonly named using uppercase letters II.Only integer values can appear as constants III.A variable can be defined with an initial value, but the reserved word final prevents it from being changed IV.A named constant makes computations that use it clearer

Read Details

You can invoke the println and print methods on which object…

You can invoke the println and print methods on which object?

Read Details

When hand-tracing the loop in the code snippet below, which…

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); }

Read Details

Which statement is true about variable names in Java?

Which statement is true about variable names in Java?

Read Details

What is the output of the following code snippet? int counte…

What is the output of the following code snippet? int counter = 1; for (double i = 0.01; i

Read Details

Posts pagination

Newer posts 1 … 51,074 51,075 51,076 51,077 51,078 … 58,779 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top