题目为如下代码的执行结果: 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…
题目如下: 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…
判断如下代码的执行结果: 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…
题目——如下代码的执行结果: 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;}…
喵哈哈村与哗啦啦村的大战(一) 最大值就是全部+3,最小值就是全部-3,注意不能降为负数. #include<bits/stdc++.h> using namespace std; const int maxn = 105; int a[maxn],n; int main(){ while(cin>>n){ int ans1=0,ans2=0; for(int i=0;i<n;i++){ cin>>a[i]; ans1+=a[i]+3; ans2+=max(0,a…