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
how to compare numbers yes
while loops no
Graphical User Interfaces no
2. The String variable today contains the text "September 18, 2006". What will be the value of the string newString after the following command:
newString = today.substring(0,8); Septembe
3. What is the main difference between storing an integer and storing a string in the computer? Hint: if you have a variable newString of type String, what exactly is stored in this variable?
Answer: an integer variable contains the actual value of this integer, but a String variable contains the address where the actual value of the string is stored4. A programmer defined a new object for writing into a file:
PrintWriter out = new PrintWriter("a:\\myfile.java");and started writing into the file by using the following command:
out.println("This is a test.");If this file originally contained your Lab 3, what will be the contents of this file after this command?
Answer: the computer will overwrite whatever you had before, so after this command, the file will contain only one like "This is a test."