第一题
/**
* 你们能看出运行结果是多少吗?
*/
public static void main(String[] args) {
int x=5;
boolean b1=true;
boolean b2=false;
if((x==4)&&!b2)
System.out.println("1");
System.out.println("2");
if((b2=true)&&b1)
System.out.println("3");
}
第二题
/**
*
*/
public class Base {
public static final String FOO="foo";
public static void main(String[] args) {
Base b=new Base();
Sub s =new Sub();
System.out.println(Base.FOO);
System.out.println(Sub.FOO);
System.out.println(b.FOO);
System.out.println(s.FOO);
System.out.println(((Base)s).FOO);
}
class Sub extends Base{
public static final String FOO="bar";
}
}
|
|