深圳茁壮笔试题
2023-07-06
1、TRUE(大写)不是关键字
2、int a =10,b=20,c=11,d=17;
int K = a>b?a:c>d?d:ba+c?d:b;(这后面整个都是一个表达式)
System.out.println(K); 31
3、以下定义的类,可以包外继承的有:
a. public final Class One
b. class Two
c. protected Class Three
d. Public Class Four
4、int i= 5/0; 编译没错,运行有错
5、public abstract class A
public abstract void operation_1();
public void operation_2();
能符合以下类图的选项有:A B C E
a.public class A_1 extends A
public void operation_1()
b.public abstract class A_2 extends A
public void operation_1()
c.public abstract class A_3 extends A
d.public class A_4 extends A
e.public class A_5 extends A
public void operation_1()
public void operation_2()
f.public class A_6
private A a ;
6、String[] arr1 =“a”,”b”,”1″,”c”,”b”;
List lst1 = new ArrayList();
lst1.add(“d”);
Collections.addAll(lst1,arr1);
System.out.println(lst1);
Set set1 = new HashSet();
set1.add(“d”);
Collections.addAll(set1, arr1);
System.out.println(set1);
运行结果: [d, a, b, 1, c, b]
[d, a, c, b, 1]
7、Short a = new Short(45); 编译有错
8、int[] arr = 1,3,3,2,8;
String str = “”;
int i=0;
public void doIt()
for(;i if(arr[i]>arr[i+1])
str=arr[i]+arr[i+1]+str;
break;
else if(arr[i] str=arr[i]+str+arr[i+1];
i++;
continue;
else
str+=arr[i];
i++;
System.out.println(i);
System.out.println(str);
打印结果:i=2;str=5133
9、public class Final
void play(String str)
class A
String dose(short flag)
String a =”";
switch(flag)
case 1:
a+=”a”;
break;
case 32768:
a+=”b”;
break;
default :
flag=1;
a+=”c”;
continue;
System.out.println(str);
找错:①32768 超过short类型的
②最后输出str时有错,内部类调用的参数,必须是final修饰的