填空题

请写出下列程序的输出结果____。
interface Com{
public void speak();
}
public class E {
public static void main(String args[]) {
Com p=new Com() {
public void speak() {
System.out.println("pisainterface");
}
};
p.speak();
}
}

下载APP答题
由4l***u9提供 分享 举报 纠错

相关试题

填空题 请写出下列程序的输出结果____。
class Cry {
public void cry() {
System.out.println("hello");
}
}
public class E {
public static void main(String args[]) {
Cry hello=new Cry() {
public void cry() {
System.out.println("helloeveryone");
}
};
hello.cry();
}
}

填空题 请说出E类中【代码1】,【代码2】的输出结果____。(两个结果之间用英文状态下的#隔开)
interface Com {
int add(int a,int b);
}
abstract class A {
abstract int add(int a,int b);
}
class B extends A implements Com{
public int add(int a,int b) {
return a+b;
}
}
public class E {
public static void main(String args[]) {
B b = new B();
Com com = b;
System.out.println(com.add(12,6)); //【代码1】
A a = b;
System.out.println(a.add(10,5)); //【代码2】
}
}

填空题 给出下列【代码】注释标注的代码的输出结果。
public class Hello{
public static void main (String args[]) {
boolean boo = false;
int x = -100 ;
boo = ((x=10)>9)&&((x=100)>99);
System.out.print(boo+"hello"+x); //【代码】____

}
}

填空题 请写出 AAA 类中 System.out.print 的输出结果____。
class BBB {
int n;
static int sum=0;
void setN(int n) {
this.n=n;
}
int getSum() {
for(int i=1;i<=n;i++)
sum=sum+i;
return sum;
}
}
public class AAA {
public static void main(String args[]) {
B b1=new B(),b2=new B();
b1.setN(3);
b2.setN(5);
int s1=b1.getSum();
int s2=b2.getSum();
System.out.print(s1+s2);
}
}

填空题 给出下列【代码】注释标注的代码行的输出结果____。
class A{
int f(int x,double y){
return x+(int)y;
}
int f(int x,int y){
return x*y;
}
}
public class TTT{
public static void main (String args[]) {
A a= new A();
System.out.printf("%d:%d",a.f(10,10.0),a.f(10,10)); // 【代码】
}

填空题 请说出E类中【代码1】,【代码2】的输出结果____。(两个结果之间用英文状态下的#隔开)
class A {
double f(double x,double y) {
return x+y;
}
}
class B extends A {
double f(int x,int y) {
return x*y;
}
}
public class E {
public static void main(String args[]) {
B b=new B();
System.out.println(b.f(3,5)); //【代码1】
System.out.println(b.f(3.0,5.0)); //【代码2】
}
}

填空题 请写出下列程序的输出结果____。
class RedCowForm {
static class RedCow { //静态内部类是外嵌类中的一种静态数据类型
void speak() {
System.out.println("iamaredcow");
}
}
}
class BlackCowForm {
public static void main(String args[]) {
RedCowForm.RedCow red = new RedCowForm.RedCow();
red.speak();
}
}

填空题 请说出E类中标注的【代码1】~【代码4】的输出结果____。(多个结果之间用#号隔开)。
import java.io.*;
public class E {
public static void main(String args[]) {
int n=-1;
File f =new File("hello.txt");
byte [] a="abcd".getBytes();
try{ FileOutputStream out=new FileOutputStream(f);
out.write(a);
out.close();
FileInputStream in=new FileInputStream(f);
byte [] tom= new byte[3];
int m = in.read(tom,0,3);
System.out.println(m); //【代码1】
String s=new String(tom,0,3);
System.out.println(s); //【代码2】
m = in.read(tom,0,3);
System.out.println(m); //【代码3】
s=new String(tom,0,3);
System.out.println(s); //【代码4】
}
catch(IOException e) {}
}
}