有关JAVA的两个小问题

来源:百度知道 编辑:UC知道 时间:2024/05/13 00:29:10
1、 int [][]origin = new int [][]{{1,2},{3,4}};
int [][]cloned = (int [][])origin.clone();
cloned[0][0] = 10;
cloned[0][1] = 10;
System.out.print(origin[0][0]+origin[0][1]);
输出为20而不是3
而如下代码: int []origin = new int []{1,2};
int []cloned = (int [])origin.clone();
cloned[0][0] = 10;
cloned[0][1] = 10;
System.out.print(origin[0]+origin[1]);
输出为3而不是20 是什么原因?
2、public class SuperClass implements InterfaceA,InterFaceB{}
public class ChildClass extends superClass implements InterfaceC{}
ChildClass instence = new ChildClass();
请问:instance jishi ChildClass 类的实例,也是InterfaceC的实例,有事InterfaceA,InterfaceB,SuperClass 和Object类的实例 这样说对吗?详细说明一下,谢谢

int []origin = new int []{1,2};
int []cloned = (int [])origin.clone();
cloned[0][0] = 10;
cloned[0][1] = 10;
System.out.print(origin[0]+origin[1]);
这一段编译通过了?? 我在本机jdk5环境下是没通过

ChildClass instence = new ChildClass();只能说它是ChildClass的实例,因为你是这样声明的,变量的类型是在编译期就决定的,而在运行时根据其实现类不同表现出多态性