简体   繁体   中英

can subclass constructor method override superclass constructor? “java”

is it possible for subclass constructor method override the superclass constructor? since i got a question - superclass(Student), subclass(BachelorStudent), it ask me constructor method for BachelorStudent class must over-ride the Student class. is it the question is having error or something wrong? tq.

Constructors are never overriden or inherited. In fact, they cannot be called virtually.

However, you can create a constructor in the subclass which calls a constructor in the parent class.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM