Half The Characters
Reads one line of input and prints every other
character, starting with the first character.
Download files: HalfTheCharacters.java
Areas: User input and output.
Download files: HalfTheCharacters.java
Areas: User input and output.
|
|
HalfTheCharacters.java |
|
View full source |
| Question 1 |
| What is the purpose of the 'throws IOException' clause? |
| Question 2 |
| import java.io.*; imports every class found in the io package. However, only a few of the classes would need to be used. Write the import statements for these classes that would be used in lieu of the current import statement. |
| Question 3 |
| Under what conditions will this loop terminate? Do not just state the condition as written in the for-loop. Try to express it in plain English. |
| Question 4 |
| What are the possible values that i can have immediately after the last iteration of the loop? |
| Question 5 |
| What does i represent in this case? |
| Question 6 |
| What is the purpose of InputStreamReader? |
| Question 7 |
| Why is the InputStreamReader wrapped in a BufferedReader? |
| Question 8 |
| If the input line is "Hello,World", what does the program print? |
| Question 9 |
| If we initialized i to 1, would the name of the class still hold true? What would be the difference? |
| Question 10 |
| Reproduce the results of this program using a while loop instead of a for loop. You only have to produce the while loop that would be necessary. For the original program, why would the programmer choose a for loop instead of a while loop? |
