首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

联发科技笔考题

2012-10-31 
联发科技笔试题public class Dims {??? /**??? ?* @param args??? ?*/??? public static void main(String

联发科技笔试题

public class Dims {

??? /**
??? ?* @param args
??? ?*/
??? public static void main(String[] args) {
??? ??? // TODO Auto-generated method stub

??? ??? int[][] a = {{1,2},{3,4}};
??? ??? int[] b = (int[])a[1];
??? ??? Object o1 = a;
??? ??? int[][] a2 = (int[][])o1;
??? ??? int[] b2 = (int[])o1;
??? ??? System.out.println(b[1]);
??? }

}

运行时发生异常,在 int[] b2 = (int[])o1;处。类型不匹配

?

public class Pass {

??? /**
??? ?* @param args
??? ?*/
??? public static void main(String[] args) {
??? ??? // TODO Auto-generated method stub

??? ??? int x = 6;
??? ??? Pass p = new Pass();
??? ??? p.doSth(x);
??? ??? System.out.print(" main x = "+x);
??? }

??? void doSth(int x){
??? ??? System.out.print("doSth x = "+x++);
??? }
}
结果:

doSth x = 6 main x = 6

热点排行