Consider the classes Student and CollegeStudent, as described , and the following methods:
public static void main(String args[])
{
Student s = new CollegeStudent(...);
CollegeStudent cs = new CollegeStudent(...);
process(s);
process(cs);
} // end main
public static void process(Student aStudent)
System.out.println(aStudent.getName();
...
} // end process
a. What are the static and dynamic types of s, cs, and aStudent when the code is executed?
b. If we change the data type of the parameter aStudent from Student to CollegeStudent, will the main method execute correctly? If so, explain why; if not, explain why not and correct the method.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here