阅读程序题(给出【代码】注释标注的代码的输出结果)interface Com {int add( int a, int b);}abstract class People {abstract int add( int a, int b);}class Student extends People implements Com{public int add(int a,int b) {return a + b;}}public class 习题5_阅读3 {public static void main(String args[ ]) {Student stu = new Student ();Com com = stu;int m = com.add(12,6);People p = stu;int n = p.add(12,8);System.out.printf("%d:%d",m,n); //【代码】}}
查看答案
阅读程序题(给出【代码】注释标注的代码的输出结果)interface Com {int add(int a, int b);public static int get(int n){return n;}public default int see( int n){return n;}public default int look( int n) {return n;}}class A implements Com{public int add( int a, int b) { return a + b;}public int see(int n){ return n + 1;}}public class 习题5_阅读4{public static void main( String args[ ]) {A a = new A();int m = a.add(12,6);int n = Com.get( 12);int t = a.see(6);int q = a.look(6);System.out.printf("%d:%d:%d:%d",m,n, t,q); //【代码】 }}}
阅读程序,写出其输出结果:class ScoreException extends Exception{int m;ScoreException(int m){this.m =m;}int getMess( ){return m;}}class Teacher{public int giveScore(int score)throws ScoreException{if(score > 100 || score<0)throw new ScoreException(score);return score;}}public class E{public static void main(String args[ ]){Teacher t = new Teacher( );int m =0,n=0;try{m = t.giveScore(100);m = t.giveScore(101);}catch(ScoreException e){n = e.getMess( );}System.out.printf("%d:%d",m,n);}}
阅读程序,写出其输出结果:import java.io.IOException;public class E{public static void main(String args[ ] ){int m =10;try{methodA( );m = 100;}catch(IOException e){m = 1000;}finally{m=99;}System.out.println(m);}public static void methodA( ) throws IOException{throw new IOException( );}}
阅读程序,写出其输出结果:interface Com{int get(int a,int b);}public class E{public static void main(String args[ ]){Com com=(a,b)->{return a+b;};System.out.println(com.get(12,8));}}