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
2-D arrays no
2. What will be the result of a formatting operation String.format("%.2f", 3.141592)? Explain your answer.
Solution: the result is a string "3.14". Explanation: %.2f means that we round off the number to two digits after the decimal point3. A file data.txt contains two lines, the first line has the date September 24, the second line has the year 2007. What will be the contents of this file after applying the following code:
PrintWriter toFile = new PrintWriter("data.txt"); toFile.print("Summer is finally over. "); toFile.println("This is one of the first days of Fall."); 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: Summer is finally over. This is one of the first days of Fall.