题目内容

写出下列程序完成的功能.public class Sum{public static void main(String [] args){int j=10;System.out.println("j is : "+j);calculate(j);System.out.println("At last, j is : "+j);}static void calculate (int j){for (int i = 0;i<10;i++)j++;System.out.println("j in calculate() is: "+j);}}输出结果为:j is : ()j in calculate() is : ()At last j is :()

查看答案
更多问题

按要求回答问题abstract class SuperAbstract{void a(){…}abstract void b();abstract int c(int i);}interface AsSuper{void x();}abstract class SubAbstract extends SuperAbstract implements AsSuper{public void b(){…}abstract String f();}public class InheritAbstract extends SubAbstract{public void x(){…}public int c(int i ) {…}public String f(){…}public static void main(String args[]){InheritAbstract instance=new InheritAbstract();instance.x();instance.a();instance.b();instance.c(100);System.out.println(instance.f());}}在以上这段程序中:抽象类有:SuperAbstract和(1)(写出类名)非抽象类有:(2)(写出类名)接口有:(3)(写出接口名)AsSuper中的x()方法是(4)方法,所以在InheritAbstract中必须对它进行(5)

按注释完成程序public class Leaf {private int i = 0; //此属性值用于检验Leaf increment(){ //定义方法increment(),返回值是Leaf类的对象i++;return ( ) ;//将当前对象的地址作为返回值返回}void print() {System.out.println(" i = " + i);}public static void main(String args[]){Leaf x = (); //创建Leaf类的对象xx.increment().increment().increment().print();}//多次调用方法increment(),返回的都是x的地址,i 值表示调用次数}输出结果为 i = ()

按注释提示完成文件复制的程序//FileStream源代码如下:import java.io.*;class FileStream {public static void main(String args []) {try {File inFile = new File("file1.txt"); //指定源文件File outFile = new File("file2.txt"); //指定目标文件FileInputStream fis =();FileOutputStream fos = new FileOutputStream(outFile);int c;//逐字节从源文件中输入,再输出到fos流while ((c = fis.read ())!=-1)();fis.close();fos.close();}catch (Exception e) {System.out.println("FileStreamsTest: "+e);}}}

完成代码计算10的阶乘并输出,把下面代码补全:int result = 1;for(int i = 2; i <= 10; i++){}System.out.println(“result=”+ result);

答案查题题库