Show the output of the following code:public class Test {  p…

Show the output of the following code:public class Test {  public static void main(String[] args) {    System.out.println(f2(2, 0));  }  public static int f2(int n, int result) {    if (n == 0)      return 0;    else      return f2(n – 1, n + result);  }}

Fill in the code to complete the following method for comput…

Fill in the code to complete the following method for computing factorial.  /** Return the factorial for a specified index */  public static long factorial(int n) {    if (n == 0) // Base case      return 1;    else      return _____________; // Recursive call  }

After the following program is finished, how many bytes are…

After the following program is finished, how many bytes are written to the file t.dat?import java.io.*;public class Test {  public static void main(String[] args) throws IOException {    DataOutputStream output = new DataOutputStream(      new BufferedOutputStream(FileOutputStream(“t.dat”)));    output.writeChar(‘A’);    output.close();  }}

After the following program is finished, how many bytes are…

After the following program is finished, how many bytes are written to the file t.dat? import java.io.*;public class Test {  public static void main(String[] args) throws IOException {    DataOutputStream output = new DataOutputStream(      new FileOutputStream(“t.dat”));    output.writeShort(1234);    output.writeShort(5678);    output.close();  }}