scjp考试准备 - 4

好吧这道题我丢脸了,竟然做错了。

如下程序的输出结果是:

class Alligator{
    public static void main(String[] args){
        int[]x[] = {{1,2},{3,4,5},{6,7,8,9}};
        int[][]y = x;
        System.out.print(y[2][1]);
    }
}

 

最后输出7。

我是从1开始数的。

scjp考试准备 - 4,布布扣,bubuko.com

时间: 2024-12-29 06:42:22

scjp考试准备 - 4的相关文章

scjp考试准备 - 3

判断如下程序的最终输出值: import java.util.*; public class Quest{ public static void main(String[] args){ String[] colors = {"blue", "red", "green", "yellow", "orange"}; Arrays.sort(colors); int s2 = Arrays.binarySear

scjp考试准备 - 5

如下代码,在所指示的位置插入代码能够正常编译: class Alpha{ public void bar(int... x){}; public void bar(int x){}; } public class Beta extends Alpha{ //insert code here } 有如下选项: A: private void bar(int x){} B: public void bar(int x){} C: public int bar(String x){return 1;}

scjp考试准备 - 2

判断如下代码的执行结果: public class Spock{ public static void main(String[] args){ Long tail = 2000L; Long distance = 1999L; Long story = 1000L; if( (tail>distance) ^ ((story*2)==tail ) ) System.out.print("1"); if((distance+1 !=tail) ^ ((story*2)==dist

scjp考试准备 - 1

判断如下代码最后的执行结果. public class Breaker{ static String o = ""; public static void main(String[] args){ z: o = o+2; for(int x=3; x<8; x++){ if(x==4) break; if(x==6) break z; o = o+x; } System.out.print(o); } } 这道题考察的重点是Java的循环控制.主要考察break语句及循环标签.

scjp考试准备 - 6

  题一,如下代码的执行结果: class Person{ String name = "No name"; public Person(String nm){name = nm;} } class Employee extends Person{ String empID = "0000"; public Employee(String id){empID = id;} } class EmployeeTest{ public static void main(S

scjp考试准备 - 10

题目为如下代码的执行结果: class Building{} public class Barn extends Building{ public static void main(String[] args){ Building build1 = new Building(); Barn barn1 = new Barn(); Barn barn2 = (Barn)build1; Object obj1 = (Object)build1; String str1 = (String)build

scjp考试准备 - 9

题目为如下代码的执行结果: abstract class Vehicle{ public int speed(){ return 0; } } class Car extends Vehicle{ public int speed(){ return 60; } } class RacerCar extends Car{ public int speed(){ return 150; } public void run(){ System.out.println("I'm running...&

scjp考试准备 - 8

题目,如下代码的执行结果: import java.util.ArrayList; class Pizza{ ArrayList toppings; public final void addTopping(String topping){ toppings.add(topping); } public void removeTopping(String topping){ toppings.remove(topping); } } class PepperoniPizza extends Pi

scjp考试准备 - 11

题目如下: interface Foo{} class Alpha implements Foo{} class Beta extends Alpha{} public class Delta extends Beta{ public static void main(String[] args){ Beta x = new Beta(); //insert code here } } 将下面哪一行代码插入如上所示的位置中会导致java.lang.ClassCastException: A. A