题目为如下代码的执行结果: 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...&…
题目为如下代码的执行结果: 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…
题目——如下代码的执行结果: class Hello{ String title; int value; public Hello(){ title += " World!"; } public Hello(int value){ this.value = value; title = "Hello"; Hello(); } } public class Test{ public static void main(String[] args){ Hello c =…
题一,如下代码的执行结果: 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(Str…
如下代码,在所指示的位置插入代码能够正常编译: 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;}…
判断如下代码的执行结果: 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…
题目如下: 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…