import java.io.*; import java.text.*; public class Student { private String name; //members private String major; Student() throws IOException //constructor { BufferedReader in =new BufferedReader (new InputStreamReader(System.in)); System.out.print("Please enter the student's name: "); name=new String(); //call constructor, allocate memory name=in.readLine(); //read in name System.out.print("Please enter the student's major: "); major=new String(); //call constructor, allocate memory major=in.readLine(); //read in name } public String getName() //method { return name; } public String getMajor() //method { return major; } public static void main(String args[]) throws IOException { Student Anne = new Student(); //declare an object //Allocate memory, and call the constructor //Notice that the object is used to call the method: System.out.println("Name: " +Anne.getName()); System.out.println("Major: "+Anne.getMajor()); } }