Quiz Space

Programming Concepts using Java · End Term · 3 Sept 2023 · May 2023 term · Set QPD1-S2

Question 10: Consider the code given below.\ Assume that, before exec…

Question 10

+4 marksOne correct option

Consider the code given below.
Assume that, before execution of the given code, the files "f1.txt" and "f2.txt" have the following text in them.
JavaScript is a scripting language

java
import java.io.*;
public class TestFile {
public static void main(String[] args) {
try {
var out = new FileOutputStream("f1.txt", true);
var dout = new DataOutputStream(out);
dout.writeBytes(", enables you to create dynamically updating content");
dout.close();
var out2 = new FileOutputStream("f2.txt", false);
var dout2 = new DataOutputStream(out2);
dout2.writeBytes(", enables you to create dynamically updating content")
dout2.close();
}
catch(IOException e) {
System.out.println(e);
}
}
}

Choose the correct option regarding the contents of f1.txt and f2.txt after the program finishes execution.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • C

Question 10 of 23 in the IIT Madras BS Programming Concepts using Java (Java) End Term paper sat on 3 Sept 2023, in the May 2023 term (IIT M DIPLOMA ET1 EXAM QPD1 S2 03 Sep). It carries 4 marks.

More questions from this paper

  1. Q1Method Stream.iterate(e, f) returns an infinite sequential ordered Stream produced by iterative application of a functi…
  2. Q2Consider the following java code What will the output be?
  3. Q3Consider the java code given below What will the output be?
  4. Q4Consider the Java code given below.\ You may make use of the method description given below.\ getOrDefault(Object key, …
  5. Q5Consider the Java code given below Choose the correct option(s) to be filled in place of CODE BLOCK so that the program…
  6. Q6Consider the following java code What will the output be?
  7. Q7Consider the following java code Identify the first assert statement that throws the AssertionError when the class is e…
  8. Q8Consider the code given below. Choose the correct option.
  9. Q9Consider the Java code given below Choose the correct option to be filled in place of CODE BLOCK so that the program ge…
  10. Q11Consider the code given below. What will the output be?
  11. Q12Consider the code given below. What will the output be?
  12. Q13Consider the Java code given below Choose the correct option(s) to be filled in place of LINE 1 so that the program gen…
  13. Q14Consider the three Java files given below.\ TestPack1.java: TestPack2.java: Test.java: Choose the correct option.
  14. Q15Consider the code given below. Which of the following is true about the given code?
  15. Q16Consider the Java program given below and select the correct option from among the given choices.
  16. Q17Consider the Java program given below. Initial State: window with Clear and Reload buttons, empty label.\ On clicking C…
  17. Q18Consider the following code Which of the following is/are possible output(s)?
  18. Q19Consider the code given below. Choose the correct option(s) to be filled in place of CODE BLOCK so that the output is: …
  19. Q20Consider the Java code given below. Choose the correct option.
  20. Q21Consider the code given below. What will the output be?
  21. Q22Figure question
  22. Q23Consider the following java code: Identify the line/s which has/have error.