关于SCJP1.4考试的一些需要注意的地方(二)

类别:Java 点击:0 评论:0 推荐:

接上文:

21.An instance sl of a class S that extends a class B,where B declares the protected member and where sl is referring to one of the following:

1.its own copy of the proteched member inherited from B

2.a copy of the protected member owned by another instance S2 fo S (and therefore inherited from B)

3.a copy of the protected member owned by an instance of a subclass of S

22. null false true 不是保留字

23.Float f1=0.0f;

       Float f2=-0.0f

       Double d1=0.0

       Double d2=-0.0

       Int i=0

       F1=f2=d1=d2=i

24.  char a=’\u0061’;

        Char \u0061=’a’;

        Ch\u0061r \u0061=’\u0061’

25.           methodA(){

  int I,j;

    if(true){i=1;}

    if(i==1){j=2;}

    System.out.println(i);  (right)

    System.out.println(j);  (wrong)

}

Reason :

If the java compiler can immediately determine the value of Boolean expression within an if() statement,it will not generate code to evaluate the expression at runtime,if the compiler can determine that the Boolean expression is always false,it will not generate code for the corresponding compound statement.

26.           constructor and abstract method can not be declared static final sychnorized native or strictfp

27.           final 变量必须赋值,否则编译无法通过

28.           int i=j; int j=1  (wrong)

int i=j; static int j=1; (right)   因为static初始化早

29.           int []a={1,2}

int []b=(int[])a.clone();   此时: a<>b

30.           stclass s=new stclass();

s=null;

s.amethod();  //valid only if the amethod() is static one

31.   String x=new String();

        String y=new String(“”);

Both x and y creat an empty string

32           min(-0.0,0.0)=-0.0

33           class A{}

class B extends A{}

class C extends A{}

A a=new A();

B b=new B();

C c=new C();

       Compiler      runtime

 a=b    right          right

 b=c;    wrong        wrong

 b=(b)c  wrong        wrong

b=(b)a;  right         may be wrong

 b=a;     wrong       wrong

 a=(a)b;   right        right

 

34. int x=6; double y=9.7;

       System.our.println((x<y)?9:8.6);   输出9.0

       System.our.println((6<9.7)?9:8.6);  输出9

35.boolean b=new boolean(“true”);

       boolean b2=new boolean(“asdfad”);

则   b=true b2=false

36.Synchnorized ―――

class method。instance method。a part in method

37.switch(k) k―――byte char int

38.wait must be called inside sychronized code

39. class A{

       static{

       System.out.println(“sdfasd”);

}

}

此部分并不是实例化一次就执行一次,而是load到jvm时执行一次,即 java A时执行一次

40 int a=(octal)5;  octal不是合法字符

 

本文地址:http://com.8s8s.com/it/it14661.htm