Forumchem - Forum with AI(ALICE BOT & HAL9000) and TTS
http://petrochemical.gronerth.com/forumchem/

Is SubClassName x = new SubClassName() a valid declaration i
http://petrochemical.gronerth.com/forumchem/viewtopic.php?f=12&t=186197
Page 1 of 1

Author:  oxaqulane [ Wed Apr 28, 2021 4:41 pm ]
Post subject:  Is SubClassName x = new SubClassName() a valid declaration i

Is SubClassName x = new SubClassName() a legitimate declaration in Java?

For example, lets say the UnderGrad and GradStudent classes are subclasses of the Student class.
Student u = new UnderGrad(); works because an UnderGrad is-a Student.
UnderGrad u = new Student(); does not labor is because a Student is not necessarily an UnderGrad (it could be a GradStudent.) So since technically(idk if this is legitimate in java) an UnderGrad is-a UnderGrad, is UnderGrad u = new Undergrad(); a legitimate declaration?

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/