I again agree with what Greg said. But to add to that, exception handling doesn't really have anything *specifically* to do with either file handling or memory allocation (whatever that means).
In Java, a method can declare the fact that it throws an Exception. There are two types of Exceptions: checked and unchecked. If a method has declared that it can throw a checked Exception (such as IOException), then the call to that method must be inside a try block (or you must delclare that method throws the Exception as well). Something like this:
import java.io.IOException;
public class Main {
public static void main(String... args){
try {
doSomethingDangerous();
}
catch (IOException e) {
e.printStackTrace();
}
}
static void doSomethingDangerous() throws IOException{
if(Math.random() < .5){
//this is not a good use of IOException but demonstrates the point
throw new IOException();
}
}
}
The classes you're using, such as Scanner, are really just Java code. In fact you can look at the code in the src.zip file that comes with your JDK. If you look at the source for Scanner, you'll see that some of its methods have declared that they can throw an IOException, so you have to put them in a try block.
Similarly, you would only have to put a constructor in a try block if it declared that it threw a checked exception.