![]() Keep in mind, if there is an Inheritance with IS – A relationship we can do Upcasting in Java in every scenario. There will not be any runtime error as, the cast is possible because at runtime animalis actually a Man even though the static type of animal is Animal. Hence we don’t get a compilation error here. So the Updated and Corrected Code would look like, Animal animal = new Man() īasically, we are telling the compiler that we know runtime type of the object. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |