以下哪些代码可编译通过且可以打印输出Equal?
A. class Check{public static void main(String args[]){int x=100;float y=100.0F;if(x==y){System.out.println(“Equal”);}}
B. class Check{public static void main(String args[]){int x=100;Integer y=new Integer(100);if(x==y){System.out.println(“Equal”);}}
C. class Check{public static void main(String args[]){Integer x=new Integer(100);Integer y=new Integer(100);if(x==y){ System.out.println(“Epual”); }}}
D. class Check{public static void main(String args[]){String x=new String(“100”);String y=new String(“100”);if(x=y){ System.out.println(“Equal”);}}}
E. class Check{public static viod main(String atgs[]){String x=new String(“100”);String y=new String(“100”);if(x==y) System.out.println(“Equal”);}}}
给出以下代码,请问以下哪些描述的正确的?public class A{AO{ }}
A. 类A可以被其他包中的类访问。
B. 类A不可以被其他包中的类访问。
C. 类A不可以被其他包中的类继承。
D. 类A可以被其他包中的类访问和继承。
E. 代码编译错误,因为公共类的构造器也必须是公共的。
给出以下代码,请问哪些是有关该方法声明的正确描述?void myMethod(String s){}
A. myMethod()方法是一个静态方法。
B. myMethod()方法没有返回值。
C. myMethod()方法是一个抽象方法。
D. myMethod()方法不能被所在的包之外的类访问。
给出以下代码,请问该程序的运行结果是什么?class A{private int x=o;static int y=1;protected int q=2;}class B extends A{void method(){System.out.println(x);System.out.println(y);System.out.println(q);}}
A. 程序编译错误,因为类B不能访问变量x。
B. 程序编译成功,打印输出012。
C. 程序编译错误, 因为不能继承一个具有私有变量的类。
D. 程序编译错误,如果移走System.out.println(x)这条语句,可使编译程序通过。
E. 程序编译错误,因为变量x未在类B中定义。