boolean b=true;
if(b=false) //把值赋值给左边,留下左边。
{
System.out.println("a");
}
else if(b)
{
System.out.println(b);
}
else if(!b)
{
System.out.println("c");
}
else
System.out.println("d");
A. a
B. true
C. c
D. d
2. 阅读下面代码:
public class Test
{
public static void main (String[ ] args)
{
char ch=’c’;
switch (ch)
{
case ‘a’:
System.out.print(“a”);
break;
case ’b’:
System.out.print(“ab”);
case ’c’:
System.out.print(“c”);
default:
System.out.print(“d”);
}
}
}
输出的结果为( )
A. a
B. b
C. c
D. cd
3. 给出以下代码,请问该程序的运行结果是什么?class Demo {
String s = "Outer";
public static void main(String[] args) {
S2s2 = new S2();
s2.display();
}
}
class S1 {
String s = "S1";
publicvoid display(){
System.out.println(s);
}
}
class S2 extends S1 {
Strings = "S2";
}
答案是什么?
4. 下面哪些语句可以通过编译( )
A. float a= 1.34f;
B. float b=1.0;
C. float c=2f;
D. float d=20;
5. 下面数组定义正确的是?()
A. int arr[]= new int[3];
B. int arr[] =new int[3]{1,2,3};
C. int [][]x =new int[][];
D. int[][] x = new int[2][];