AP Comp Sci Unit 3 + 4

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

Which of the following symbols is the "not equal" symbol? == not = != <>

!=

Which of the following is NOT a relational operator? < ? == >=

?

boolean shortCircuit = true || (5 / 0 == 0); Will the 5 / 0 == 0 operation be evaluated?

No because java already knows the end result is true.

What is the difference between == and =? a) == is used for assignment, while = is used to check for equality. b) = is used for assignment, while == is used to check for equality. c) == assigns values to objects while = assigns values to primitives. d) There is no difference. These symbols can be used interchangeably.

b

What is the output of this program? int phLevel = 9; if(phLevel < 7) { System.out.println("It is acidic!"); } if(phLevel > 7) { System.out.println("It is basic!"); } if(phLevel == 7) { System.out.println("It is neutral!"); } a) It is acidic! b) It is basic! c) It is neutral! d) It is acidic! It is basic! It is neutral!

b

Why do we use if statements in Java? a) To break out of some block of code b) To do something only if a condition is true c) To do something while a condition is true d) To repeat something for a fixed number of times

b

Which if statement is written properly? (a) if (boolean expression): // code to execute // code to execute (b) if boolean expression { // code to execute // code to execute } (c) if(boolean expression) { // code to execute // code to execute } (d) if boolean expression [ // code to execute // code to execute ]

c

Consider the code snippet below. String name = "Karel"; String checkName = new String("Karel"); boolean nameMatches = name == checkName; Note that we forced Java to create a new String object by using new and calling the String constructor.Recall that if you set two String variables to the same String literal, Java tries to be efficient and uses the same object. With this in mind, what will the value of nameMatches be? true false Cannot be determined.

false

What does this Java expression evaluate to? 80 >= 80 "true" true false This expression will error

true


Conjuntos de estudio relacionados

Psych 305 Exam 2 Part 2: Chapter 6 & 7

View Set

THE ULTIMATE TEAS COMBINATION EAT YOUR HEART OUT (ONLY SOME SCIENCE)llu

View Set

Chapter 3: Medical Expenses Insurance

View Set

Chapter 14: Nursing Management During Labor and Birth

View Set

Chapter 10- Complete 20 hours of Training

View Set

Vocab Workshop - Level A - Unit 11 - Choosing the Right Word JPJ

View Set

AAT Level 4 Financial Statements Relevent IAS/IFRS

View Set

Solving Equations with Distributive Property

View Set