What are the different types of variables in Java, and how do they differ in scope and memory allocation?