Select chapter



basics (7.papers)
constructors (1.papers)
packages (1.papers)
inheritance (7.papers)
misc (3.papers)
exceptions (5.papers)
threads (4.papers)
overloading (1.papers)
jsp (3.papers)
servlets (9.papers)
jdbc (2.papers)
util (1.papers)
xml (2.papers)
IO stream (3.papers)
Hide

Sponsored Links


  

java interview questions and answers

Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
8
import java.io.*; 
public class IOTest {
 public static void main(String[] args) throws IOException { 
  FileReader fr = new FileReader ("Input.txt") ;
  FileWriter wr = new FileWriter("Output.txt",true) ;
  int i = 0 ;
  while ((i = fr.read() )!= -1) {
   wr.write(i) ;
  }
  wr.close() ;
  fr.close() ;
 }
}
 What will happen if the code in the above is compiled and executed assuming that Input.txt is available?
  1. after the execution of code, Input.txt and Output.txt contains the same data irrespective of whether Output.txt exist or not
  2. after the execution of code, if Output.txt file exists, it does not get overwritten by the content of Input.txt
  3. Output.txt file if exists, its content is appended by the content of Input.txt
  4. The code does not compile because FileNotFoundException is not handled
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
18
Which of the following methods of the File class will delete a directory or file?
  1. The file class does not allow you to delete a file or directory
  2. remove()
  3. delete()
  4. del()
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Read more papers :