给定一个Java程序的代码如下所示,则编译运行后,输出结果是public class Test {int count = 9;public void count() {System.out.print("count=" + (count++)+" ");}public static void main(String args[]) {new Test().count();new Test().count();}}
A. count=9 count=9
B. count=10 count=9
C. count=10 count=10
D. count=9 count=10
查看答案
能与public void methodA(){ }形成重载的有
A. private void methodA(){ }
B. private int methodA(){ return 1;}
C. public void methodA(int a){ }
D. public void methodA() throws Exception{ }
阅读下面代码,将会输出public class Testa {Integer a = new Integer(10);Integer b = new Integer(10);public static void main (String[ ] args){Testa testA = new Testa();if (testA.a==testA.b){System.out.print("很");}if (testA.a.equals(testA.b)){System.out.print("好");}} }
A. 很
B. 好
C. 很好
D. 抛出NullPointerException异常
编译运行下列程序会发生()的情况public class Mystery {String s;public static void main(String args[ ] ) {Mystery m =new Mystery();m.go();}public void Mystery() {s ="Constructor";}private void go(){System.out.println(s);} }
A. 可以编译,运行时会抛异常
B. 可以编译运行,但是控制台上什么都不输出
C. 输出“constructor”
D. 输出“null”
Thing是一个类,下面的代码可以产生()个Thing类型的对象。Thing item;Thing stuff;item = new Thing();Thing entity = new Thing();
A. 1
B. 2
C. 3
D. 4