I have a class “Student” that extends an abstract class “Person”. If you were instantiating a new Student object, would you code:
Student newStudent = new Student( "John Doe" ); // Call this one 'A'
Person newStudent = new Student( "John Doe" ); // Call this one 'B'
Both forms appear to work the same, but my teacher and I keep arguing about which is preferable. I say A, she says B. I’ve looked it up in my two textbooks, and one uses A and one uses B.
So the questions are:
- What’s the difference? (if any)
- Which style is better? (if either)
And no, this is NOT a homework question.