gpt4 book ai didi

java - 哪些成员不在子类中继承?

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:41:50 24 4
gpt4 key购买 nike

我正在尝试回答以下问题:

A child class would not inherit certain members of the parent class. Name three such members.

我知道私有(private)成员不会继承到子类,默认成员不会在包外继承。谁能完成答案?

编辑:-我相信静态成员是根据下面的演示继承的

public class sup {
public static void main(String agr[]){
}

protected static int staticInt=0;
protected final int finalInt=3;
protected int protectedInt=0;
public String publicString = "";
private int privateInt=8;
}

class sub extends sup{
public void del(){
staticInt=1;
staticInt=finalInt;
}
}

最佳答案

来自 JLS for Class Member

Constructors, static initializers, and instance initializers are not members and therefore are not inherited.

关于java - 哪些成员不在子类中继承?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23103498/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com