关于逆名类!! 请各位,把自己的想法,尽量,写出来 我的疑问是: 1.逆名类可以实现多个接口吗? 2.逆名类对象的作用域 3.逆名类,实现接口的同时,可以继承其他类吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 写程序测试测试不就知道了。和SCJP考试一样,无任何实际开发意义的问题。 觉得很不实用的论题。不过还是想了一下。 1.逆名类可以实现多个接口吗? 不能。第一:没有那样的语法规则。第二:如果真的能的话,那么创建出来的实例到底由哪个接口的变量去引用呢? 2.逆名类对象的作用域 在 Java 中,任何对象的声明周期都由垃圾回收器接管。(出了使用 JNI 分配的内存) 3.逆名类,实现接口的同时,可以继承其他类吗? 不能。不过可以这样:(做了些更无聊的事) public interface TestInterface { void test1();}public interface TestInterface2 { void test2();}public class TestMain { public static void main(String[] args) { new TestInterface(){ TestInterface2 interface2 = new TestInterface2(){ @Override public void test2() { System.out.println("test2"); } }; public void test1() { System.out.println("test1"); } public void test2() { interface2.test2(); } }.test2(); }} java报错 Arraylist和Hashset的哈希函数实现问题 帮忙看看这个程序错在哪 求助:java能不能设透明Frame 关于环境变量在linux 9下jdk1.4.2怎么设置???????? 安装rose 2003 时,出现DOS窗口,一闪而过,无法安装!!!! Java Application在网上如何发布 谁能给我讲一下java的开发环境的种类? 请高手指点一些有关事务的问题 JAVA新手求助String的问题 特急!!!!!使用ERwin生成数据库表时,为什么外键约束无法生成呢? 求一只能输入正整数的正则表达式
和SCJP考试一样,无任何实际开发意义的问题。
1.逆名类可以实现多个接口吗?
不能。第一:没有那样的语法规则。第二:如果真的能的话,那么创建出来的实例到底由哪个接口的变量去引用呢?
2.逆名类对象的作用域
在 Java 中,任何对象的声明周期都由垃圾回收器接管。(出了使用 JNI 分配的内存)
3.逆名类,实现接口的同时,可以继承其他类吗?
不能。不过可以这样:(做了些更无聊的事)
public interface TestInterface {
void test1();
}public interface TestInterface2 {
void test2();
}public class TestMain {
public static void main(String[] args) {
new TestInterface(){
TestInterface2 interface2 = new TestInterface2(){
@Override
public void test2() {
System.out.println("test2");
}
};
public void test1() {
System.out.println("test1");
}
public void test2() {
interface2.test2();
}
}.test2();
}
}