1. For each of the following topics, write "yes" or "no" depending on whether this topic is covered in Chapter 4, the chapter that you were supposed to read before the class:
if-then statements yes
"and" and "or" operations yes
while loops no
2. What will be the result of a formatting operation String.format("%.1f", 1.99)? Explain your answer.
Solution: the result is a string "2.0". Explanation: %.1f means that we round off the number to one digit after the decimal point3. A file data.txt contains two lines, the first line has a word February, the second line has the number 13. What will be the contents of this file after applying the following code:
PrintWriter toFile = new PrintWriter("data.txt"); toFile.print("I am answering Quiz 4. "); toFile.println("I will do well on it."); Solution: when you write into a file, all the previous contents is overwritten with the new information. So, the file will now contain only one line: I am answering Quiz 4. I will do well on it.