java程序引入接口的概念,可弥补只允许类的 的缺憾。
查看答案
请说出下列程序的输出结果。class Cry {public void cry() {System.out.println("大家好");}}public class E {public static void main(String args[]) {Cry hello=new Cry() {public voidcry() {System.out.println("大家好,祝工作顺利!");}};hello.cry();}}
请说出下列程序的输出结果。interface Com{public void speak();}public class E {public static void main(String args[]) {Com p=new Com(){public void speak() {System.out.println("p是接口变量");}};p.speak();}}
请说出下列程序的输出结果。import java.io.IOException;public class E {public static void main(String args[]){try {methodA();} catch(IOException e){System.out.print("你好");return;}finally {System.out.println("fine thanks");}}public static void methodA() throws IOException{throw new IOException();}}
读程序,写出和程序输出格式一致的输出结果。public class J_Test {public static void mb_method(int i) {try {if(i == 1)throw new Exception();System.out.print("1");} catch(Exception ex) {System.out.print("2");return;} finally {System.out.print("3");}System.out.print("4");}public static void main(String[] args) {mb_method(0);mb_method(1);}}