1.
intj=3;
while(j)
{System.out.println(“jis“+j);
}
2.
Character流与Byte流的区别是前者是块读写,后者是字节读写
3.
public class StaticStuff {
static int x = 10;
static {
x += 5;
System.out.println("static x += 5, x = " + x);
}
public static void main(String args[]) {
System.out.println("in main");
System.out.println("x=" + x);
}
static {
x /= 3;
System.out.println("static x /= 3, x = " + x);
}
}
static在编译期间就进行赋值,jvm分为:堆,栈,静态域,常量区!!静态域存储static变量,在编译期间已经注定了x的值就是5
4.
(11)类Test1、Test2定义如下:
1.publicclassTest1
2.{publicfloataMethod(floata,floatb)throws
3.IOException{}
4.}
5.publicclassTest2extendsTest1{
6.
7.}
将以下哪种方法插入行6是不合法的。()
A、floataMethod(floata,floatb){}
B、publicintaMethod(inta,intb)throwsException{}
C、publicfloataMethod(floatp,floatq){}
D、publicintaMethod(inta,intb)throwsIOException{}
解析:package com.simple.second; class First{ public First(){ aMethod(); } public void aMethod(){ System.out.println( " First " ); } } public class Second extends First{ public void aMethod(){ System.out.println( " second " ); } public static void main(String args[]){ new Second(); } }
package com.simple.second; class First{ public First(){ aMethod(); } public static void aMethod(){ System.out.println( " First " ); } } public class Second extends First{ public static void aMethod(){ System.out.println( " second " ); } public static void main(String args[]){ new Second(); } }