问题 1
What is the purpose of the 'super' keyword in Java?
The 'super' keyword in Java is used to refer to the immediate parent class object. It is often used to call the parent class's methods, access its fields, and invoke the parent class's constructor.
Example:
Example:
class Subclass extends Superclass {
void display() {
super.display(); // calls the display method of the parent class
}
}
保存以便复习
保存以便复习
收藏此条目、标记为困难题,或将其加入复习集合。
这有帮助吗?
添加评论
查看评论