标签:java garbage-collection wrapper inheritance
>在继承中,当为子类创建对象时,是否还为其超类创建了一个对象?
我发现上述问题的答案是肯定的,它已经创建了.我对吗?
>基于它是正确的假设,我解决了这个问题,我发现答案是4.
我对吗?
>长期是原始类型还是包装类?
问题:到达最后一个括号时,有多少对象符合垃圾回收的条件?
interface Animal {
void makeNoise();
}
class Horse implements Animal {
Long weight = 1200L;//here is Long a primitive variable or a wrapper class??
//If it is a wrapper class object, I think the answer to the
// question would be 6
public void makeNoise() {
System.out.println("whinny");
}
}
public class Icelandic extends Horse {
public void makeNoise() {
System.out.println("vinny");
}
public static void main(String[] args) {
Icelandic i1 = new Icelandic();
Icelandic i2 = new Icelandic();
Icelandic i3 = new Icelandic();
i3 = i1; i1 = i2; i2 = null; i3 = i1;
}
}
解决方法:
In inheritance, when an object is created for subclass, is an object
also created for its superclass? I find the answer to the above
question is yes, its created.Am I right?
不,它在创建子类对象时不会创建超类对象.子类对象将通过继承Super Class来拥有超类功能主义者.创建子类对象时,只会创建一个对象
Is long a primitive type or wrapper class??
long是原始数据类型,Long是对应的Wrapper类.
Question : When last brace is reached, how many objects are eligible
for the garbage collection?
是的,将有6个对象,包括3个Long对象
标签:java,garbage-collection,wrapper,inheritance 来源: https://codeday.me/bug/20190725/1531177.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。