比赛中的一些题目,记录一下
1.如下代码:
byte[] array1,array2[];
byte array3[][];
int[][] array4;
假设每个数组都已经被正确初始化了,下面哪个语句会产生编译错误?
A array2 = array1;
B array2 = array3;
C array2 = array4;
2.
import java.util.*;
public class StupidString
{
private String s;
public StupidString(String s){
this.s = s;
}
public static void main(String[] args)
{
HashSet<Object> hs = new HashSet<>();
StupidString ws1 = new StupidString("I'm stupid.");
String s1 = new String("I'm stupid.");
StupidString ws2 = new StupidString("I'm stupid.");
String s2 = new String("I'm stupid.");
StupidString ws3 = new StupidString("Yes, rather stupid.");
hs.add(ws1);hs.add(s1);hs.add(ws2);hs.add(s2);hs.add(ws3);
System.out.println(hs.size());
}
}
<span style="font-size:18px;">请问编译运行的结果是什么?</span>
3
int i=100;
for(i=0;i<100;i--){
for(i=200;i>=100;i--){
while(i == 100){
i *= i;
}
}
}
System.out.println(i);
请问编译运行的结果是什么?4.
int a = 4,b = 6,c = 3;
String s = "abc";
System.out.println(a+b+s+c);
请问编译运行的结果是什么?
5.
class GoodJob extends Thread
{
int x = 0;
public class Runner implements Runnable
{
public void run(){
int current = 0;
for(int i=0;i<4;i++){
current