• 2022-06-09
    以下代码运行后输出的内容( )public class Main { public static double div(int a, int b) { return (double)a/b; } public static int div(int a, int b) { return a/b; } public static void main(String[] args) { System.out.println(div(5, 2)); } }
    A: 2.5
    B: 2
    C: 输出内容不确定
    D: 程序错误,无法运行
  • D

    内容

    • 0

      下面程序运行结果为___________________。public class MyClass{ private static int a = 19; public static void modify(int a){ a = a + 5;} public static void main(String[] args){ modify(a); System.out.println(a); }}

    • 1

      以下程序的运行结果是______ class A{public int getNumber(int a){return a+1;}}class B extends A{public int getNumber(int a, char c){return a+2;} public static void main(String[] args) {B b=new B();System.out.println(b.getNumber(0));} }

    • 2

      请阅读下面的程序 public class Demo { public static void sum(int a, int b) { System.out.println("int:" + (a + b)); } public static void sum(int a, float b) { System.out.println("float:" + (a + b)); } public static void sum(int a, double b) { System.out.println("double:" + (a + b)); } public static void main(String[] args) { int a = 10; long b = 20; sum(a, b); } } 下列选项中,哪一个是程序的运行结果()

    • 3

      以下程序运行结果是 public class Test { public static void main(String[] args) { int a=1,b[]={2}; add(a); add(b); System.out.println(a+","+b[0]); } static int add(int x){ x++; return x; } static void add(int[] x){ x[0]++; } }

    • 4

      下列代码能否正常运行,如果能够正常运行,输出结果是什么? public class TestClass { public static void main(String[] args) { int num1=5; int num2=5; class InnerClass{ public int add(){ return num1+num2; } }; InnerClass in=new InnerClass(); System.out.println(in.add()); } }