Thursday, 16 July 2009

Java Certification Question 0036

Assuming any exception handling has been set up, which of the following will create an instance of the RandomAccessFile class
1) RandomAccessFile raf=new RandomAccessFile("myfile.txt","rw");
2) RandomAccessFile raf=new RandomAccessFile( new DataInputStream());
3) RandomAccessFile raf=new RandomAccessFile("myfile.txt");
4) RandomAccessFile raf=new RandomAccessFile( new File("myfile.txt"));



Answer :
1) RandomAccessFile raf=new RandomAccessFile("myfile.txt","rw");
The RandomAccessFile is an anomaly in the Java I/O architecture. It descends directly from Object and is not part of the Streams architecture.

No comments:

Post a Comment