题目内容

请写出下面程序中【代码】的输出结果interface A {double f(double x,double y);}class B implements A {public double f(double x,double y) {return x*y;}int g(int a,int b) {return a+b;}}public class Main {public static void main(String args[]) {A a = new B();System.out.println(a.f(3,5)); //【代码1】B b = (B)a;System.out.println(b.g(3,5)); //【代码2】}}

查看答案
更多问题

接口中也能声明变量。()

A. 对
B. 错

Java8之后,接口中也能定义非抽象的不加default修饰的方法。()

A. 对
B. 错

可以在接口中只声明常量,不定义任何方法。()

A. 对
B. 错

Java8之后,接口中可以定义private方法。()

A. 对
B. 错

答案查题题库