MCQ Questions
Q.1.
Write a statement that declares a PrintWriter reference variable named output and initializes it to a reference to a newly created PrintWriter object associated with a file named "output .txt". (Do not concern yourself with any possible exceptions here- assume they are handled elsewhere.)
  • 0%
    PrintWriter output=new PrintWriter(outfile);
  • 0%
    new PrintWriter(output)
  • 0%
    PrintWriter output = new PrintWriter("output.txt");
  • 0%
    PrintWriter output = new PrintWriter("textfile.txt");
Q.2.
Given an initialized String variable output, write an expression whose value is a reference to a newly created PrintWriter object associated with a file whose name is contained in output. (Do not concern yourself with any possible exceptions here-- assume they are handled elsewhere.)
  • 0%
    PrintWriter output = new PrintWriter("output.txt");
  • 0%
    PrintWriter output=new PrintWriter(outfile);
  • 0%
    String logfileName;
  • 0%
    new PrintWriter(output)
Q.3.
Declare a local variable output that is suitable for referring to an object that provides methods for writing to a text file.
  • 0%
    String logfileName;
  • 0%
    PrintWriter output = new PrintWriter("textfile.txt");
  • 0%
    PrintWriter output = new PrintWriter("output.txt");
  • 0%
    PrintWriter output=new PrintWriter(outfile);
Q.4.
Write an expression whose value is a reference to a newly created PrintWriter object associated with a file named "output .txt". (Do not concern yourself with any possible exceptions here- assume they are handled elsewhere.)
  • 0%
    new PrintWriter(output)
  • 0%
    new PrintWriter("output.txt")
  • 0%
    PrintWriter output=new PrintWriter(outfile);
  • 0%
    PrintWriter output = new PrintWriter("output.txt");
Q.5.
Declare a variable logfileName that is suitable for holding the name of a file.
  • 0%
    new PrintWriter(output)
  • 0%
    String logfileName;
  • 0%
    PrintWriter output = new PrintWriter("textfile.txt");
  • 0%
    myFile = new File ("input.dat");