• 2022-06-19
    对于下面代码,表述正确的是() interface A{ public default void test(int a){ System.out.println(a); } public static void test1(int a){ System.out.println(a); } }
    A: 语法错误,test方法不允许定义方法体
    B: A接口的实现类的实例可以调用test方法
    C: A接口的实现类的实例可以调用test1方法
    D: 可以通过A接口调用test1方法
  • B,D

    内容

    • 0

      有如下代码,则该程序运行时输出结果是。 class Test{ static int i=0; public void show() { i++; System.out.println(i); } } public class Demo { public static void main(String[] args) { Test test=new Test(); test.show(); } }

    • 1

      中国大学MOOC: 如下所示的Test类的Java程序中,共有几个构造方法()。 public class Test{ private int x; public Test(){} public void Test(int i){ this.x=i; } public Test(String str){} }

    • 2

      (6-6)请阅读程序,写出程序运行结果。 class Test{ static int x=10; int y=99; { y=y+10; } static { x=x+5; } { y=y+10; } static { x=x+5; } public Test() {//构造方法 x=x+5; } { System.out.println(x*y); } } public class Demo11 { public static void main(String[] args) { Test t1=new Test(); Test t2=new Test(); } }

    • 3

      抽象类A和抽象类Test的定义如下: abstract class A { abstract int getInfo() { } } public class Test extends A { private int a = 0; public int getInfo() { return a; } public static void main(String args[]) { Test b= new Test(); System.out.println(b.getInfo()); } } 关于上述代码说明正确的是_________

    • 4

      分析程序,将代码补充完整public class Test { ________ __ int k=5; public static void main(String[] args){ Test t1=new Test(); t1.k++; System.out.println(Test.k); }}