• 2022-06-09
    以下代码的运行结果是public class Demo{public static void main(String[] args){int c=Math.min(56,42);System.out.print(c);}
    A: 56
    B: 42
    C: 98
    D: 14
  • B

    内容

    • 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: 运行错误