Computer Science AP - Lab 20
For the following code segments, write
down (on paper) solutions to the problems, or the missing sections in
order to make them work as they
are described. Do not print this page, nor your answers.
Write them with pen or pencil as neatly as possible (for practice on
the AP exam) Do NOT print out the solutions from your computer.
1) Write the following method such that it opens the
filename given in the String paremeter to the method and then prints
out the 2nd line from the text file. (Remember to
have a try/catch clause!)
public void secondline(String fname) {
}
2) Write a method that converts a string given as a
parameter into an integer (and returns the value). Make sure you
handle potential errors from invalid input. (like "three")
public int converttoint(String input) {
}