Services
Discover
Ask a Question
Log in
Sign up
Filters
Done
Question type:
Essay
Multiple Choice
Short Answer
True False
Matching
Topic
Computing
Study Set
Java Foundations
Exam 4: Conditionals and Loops
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 21
Multiple Choice
Suppose we want to condition an if statement on whether two String objects, referenced by stringOne and stringTwo, are the same. Which of the following is the correct way to achieve this?
Question 22
True/False
The following snippet of code will not compile because the second part of the if statement needs to be on the second line. if(a < b) System.out.println("a is less than b");
Question 23
Short Answer
Rewrite the following code fragment using a for loop instead of a while loop. int i = 0; while(i < 50) { System.out.println(i); i+=2; }
Question 24
Multiple Choice
Which of the following logical operators has the highest precedence?
Question 25
Essay
What is wrong with the following snippet of code? Rewrite it so it produces the correct output. if(a < b) if(a == c) System.out.println(“a < b and a == c”); else System.out.println(“a is not less than b”);
Question 26
True/False
A while statement always executes its loop body at least once.
Question 27
Essay
Write a code fragment that allows a user to continue inputting numbers until she enters a sentinel value of 0. Then print the sum of all the numbers she entered. You may assume that a Scanner object called input has already been created.