A: 56
B: 42
C: 98
D: 14
举一反三
- (7-1)以下程序的运行结果是( )。 class A{ A(){ System.out.print(10); } } public class Demo extends A { public static void main(String[] args) { new A(); new Demo(); } }
- 以下程序的运行结果是:() public class Increment{ public static void main(String args[]) { int a; a = 6; System.out.print(a); System.out.print(a++); System.out.print(a); } }
- 以下程序的运行结果是 public class test{ public static void main(String[] args) { int a; a = 6; System.out.print(a); System.out.print(a++); System.out.print(a); } } A: 666 B: 667 C: 677 D: 676
- 以下程序的运行结果是:( )public class Increment{ public static void main(String[] args) { int a; a = 6; System.out.print(a); System.out.print(a++); System.out.print(a); System.out.print(--a); System.out.print(a); }} A: 66666 B: 66766 C: 67766 D: 67666
- {下面程序编译运行的结果是( )class Demo <;T>; {void setData(T a){System.out.print(a);};}public class Demo2015 {public static void main(String[]a){Demo<;String>; d = new Demo<;String>;();d.setData("a");d.setData(1);}}} A: a B: 1 C: a1 D: 编译错误
内容
- 0
定义类Block和类Demo,运行Demo的输出结果是。 class Block{ {//代码1 System.out.print("1"); } static{//代码2 System.out.print("2"); } {//代码3 System.out.print("3"); } public Block() {//代码4 System.out.print("4"); } static void show() {//代码5 System.out.print("5"); } static {//代码6 System.out.print("6"); } } //定义测试类Demo public class Demo { public static void main(String[] args) { new Block().show(); new Block() } }
- 1
以下代码程序运行后输出结果为public class Main { public Main() { System.out.print("main "); } public Main(String s) { this(); System.out.print("main with "+s); } public static void main(String[] args) { Main main = new Main("wow"); } } A: main with main wow B: mainmain with wow C: main main with wow D: main with wowmain
- 2
阅读下段代码片段,选择正确的运行结果 public static void main(String[] args) { { int a = 1; System.out.print(a); } { int a = 2; System.out.print(a); } int a = 3; System.out.print(a); }
- 3
阅读以下代码: public class foo{ public static void main (String[] args){ String s; System.out.println("s=" + s); 输出结果应该是
- 4
已知:class C { public static void main(String[] args) { print(); } public static void print() { static int i; System.out.println(++i); }} A: 0 B: 1 C: 编译错误 D: 运行错误