Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

# 1 Analyze the following code: int number; Keyboard k; k = new Keyboard( ); Sys

ID: 3569272 • Letter: #

Question

# 1 Analyze the following code:

int number;

Keyboard k;

k = new Keyboard( );

System.out.println("Enter a number:");

number = k.readInt( );

    if (number <= 0)

    {

      System.out.println(number);

    }

A. The if statement is wrong because it does not have the else clause;

or D. number entered from the keyboard cannot be negative.

# 2 Analyze the following code:

int number;

Keyboard k;

k = new Keyboard( );

System.out.println("Enter a number:");

number = k.readInt( );

  

if (number <= 0)

{

      System.out.println(number);

}

System.out.println(number);

number is printed out twice if number is positive;

# 3 Which of the following is equivalent to (x > 1).

Consider the following code fragment when answering questions 4

B.   If number is zero, number is displayed;

Explanation / Answer

1. B. If number is zero, number is displayed; because condition is number is less than or equal to 0.

2. C.   number is printed out twice if number is negative; Once inside the loop condition is number is less than or equal to 0
and once outside the loop.

3. !(x <= 1) because boundary condition x = 1 also gives the correct result.

4. C. an object of class String.

5. a variable because it's of primitive data type.

6. B.   a class. Keyboard is a class and k is the object.

7. C.a String value

8. String

4 becasue it has 4 parameters.

9. 11 300

10. a -> String
b -> Boolean
c -> int
z -> String

11. done -> String
n -> int
y -> String
k -> Keyboard
z -> String

12.

if( a > b){
   System.out.println(