1.
int x = 23; //先让x除以3然后在让x除((x/3)=7)取余数 x%=x/3; 输出x的值为2 |
2
float f1[],f2[]; f1 = new float[10]; f2 = f1; System.out.println("f1[0]"+f1[0]); System.out.println("f2[0]"+f2[0]); 输出结果为0.0 ①byte short int long 这四种基本数据类型数组默认值为0 ②float double 这两种数组默认值是0.0 ③char这种类型数组默认值为空格 ④boolean类型数组默认值为false |
3
关于Java 类的加载过程,下面哪些描述是正确的(A C ) |
4
String a = "ABCD"; String b = a.toLowerCase();//转换为小写LowerCase英文意思就是小写字母 System.out.println(b); b.replace('b', 'd');//替换b替换成c b.replace('b', 'c'); System.out.println(b);//调用替换后的字符是不成功的调用替换的方法是可以的。如下 System.out.println(b.replace('b', 'd')); |
5.
单例模式可以扩展成多例模式吗? 不行的,只存在一个实例的
|
6.
ArrayList ac = new ArrayList(); ac.add("AAAAA"); ac.add("BBBB"); ac.add("CCCC"); ac.add("DDDD"); Iterator iter = ac.iterator(); for(int i =0;i<ac.size();i++){ System.out.println(ac.get(i)); System.out.println(ac[i]);//错误的ac[i] 语法报错编译无法通过。 }//输出的结果为AAAABBBBCCCCDDDD; |
7.
public class Test_1 { public static int output = 0; public static void foo(int i){ try{ if(i ==1){ throw new Exception(); } output = 1; }catch(Exception e){ output += 2; return ; }finally{ output += 3; } output +=4; } public static void main(String[] args) { foo(1); String x = "2"; x+="5"; System.out.println(x);//输出为25 System.out.println(output);//上面代码输出为23 } } 字符串String的+的话是拼接是2拼接起来
|
8.
方法resume()负责恢复哪些线程的执行( D)。 |
9
class ThreeException extends Exception{} static int count = 0; public static void main(String[] args) { while (true){ try{ if(count++ == 0) //a++是先返回a在+1 ++a的话是先+1在返回a throw new ThreeException(); System.out.println("NO Exception"); }catch(ThreeException e){ System.out.println("ThreeException"); }catch(Exception e){ System.out.println("Exception"); }finally{ System.out.println("finally"); if(count == 2) break; }//执行的结果是ThreeException,finally,NO Exception,finally |
10.
<servlet-mapper> <servlet-name>test</servlet-name> <servlet-pattern>*.abc</servlet-pattern> </servlet-mapper> 可以访问的http://servername/test.abc |
11.
public class HelloA { public HelloA(){ System.out.println("我是helloA"); } { System.out.println("我是没有修饰符的helloA"); } static { System.out.println("我是static的 helloA"); } }
public class HelloB extends HelloA { public HelloB(){ System.out.println("我是helloB"); } { System.out.println("我是没有修饰符的helloB"); } static { System.out.println("我是static的 helloB"); } }
public class Test_2 { public static void main(String[] args) { new HelloB(); } }
打印为 我是static的 helloA 我是static的 helloB 我是没有修饰符的helloA 我是helloA 我是没有修饰符的helloB 我是helloB |
12
public class Dl { /*private static final Dl dl = new Dl(); private Dl(){} private static Dl getNew(){ return dl; }*/ private static Dl dl; public static Dl getNew(){ if(dl == null){ dl = new Dl(); } return dl; } } 单利的两种模式 |
13
一个简单的ajax $.ajax({ type :"post", url:"dopost", data:100, dataType: "json", success :function(data){
} }); |