Printing/User Input
All things Loops and If Statements
Math, Operators, and De Morgan's Law
Variables and Types
Short Circuit Evaluation and Casting
100

What is the Java command to display text on the screen?

System.out.println();

100

What is the purpose of a for loop in Java?

To iterate a specific number of times.

100

What are the basic arithmetic operators in Java?

The basic arithmetic operators in Java are + (addition), - (subtraction), * (multiplication), / (division), and % (modulos).

100

What is a variable in Java?

A variable in Java is a container that holds a value which can change during the execution of a program.

100

How does short-circuit evaluation affect the evaluation of logical expressions in Java?

Short-circuit evaluation can improve performance and prevent errors by only evaluating the necessary parts of a logical expression.

200

How do you take user input in Java?

By using the read command followed by whatever variable type (ex: readLine, readBoolean, readInt, etc.)

200

Explain the syntax of a while loop in Java.

while(condition) 

       // code block;

}

200

Explain the difference between the increment (++) and decrement (--) operators in Java.

The increment (++) operator increases the value by 1, while the decrement (--) operator decreases the value by 1.

200

Explain the difference between int and double in Java.

int is a data type for whole numbers, while double is a data type for decimal numbers.

200

What is casting in Java?

Casting is the process of converting a value from one data type to another in Java.

300

Explain the difference between print and println in Java.

The println method prints the text and moves to the next line, while the print method prints the text without moving to the next line.

300

How do you write an if statement with multiple conditions in Java?

Use the && (and) or || (or) operators to combine multiple conditions in an if statement.

300

Explain why we use == and for primitive types and equals() for non-primitive types.

== is able to compare only numbers or between 2 options for booleans, while equals() compares the actual contents of the strings which can be made up of numbers, letters, and symbols.

300

How do you concatenate two Strings in Java?

By using the + operator

300

When would you need to use casting in Java?

Casting is needed when you want to convert a value from one data type to another, especially when there is a possibility of data loss.

400

What will this code segment output if the user inputs the number 10?

int yourInteger = readInt("Please input a number");
System.out.println(yourInteger);

10

400

Which statement can we use inside of a loop-and-a-half to end it?

break;

400

How do you check if a number is greater than or equal to another number in Java?

Using the >= operator.

400

How can you declare an integer variable x with a value of 10 in Java?

int x = 10;

400

In the following line of code:

boolean shortCircuit = true || (5 / 0 == 0);

Will the 5 / 0 == 0 operation be evaluated?

No

Since true || (anything) is equal to true, there is no need to evaluate the second part of the boolean expression, Java already knows that the end result will be true. So the 5 / 0 == 0 operation is never evaluated.

500

Which of these characters can a Java method name start with?

(I) Letters

(II) Numbers

(III) Underscore

(IV) $ Sign

*HINT* There's more than 1

I, III, and IV

500

What is the output of the following code snippet:

int x = 5;

while (x > 0) 

{
      System.out.print(x);
      x--;
}

54321

500

Use De Morgan's Law to simplify the following expression:

  !(A && B)

!A || !B

500

What is the proper syntax to initialize a double called temperature to have the value 70.4?

double temperature = 70.4;

500

What will this java expression evaluate to?

(int) 9.9;

9

M
e
n
u