Home Tutorial Java Scjp Part10 SCJP Module-10 Question-10


Share on Google+Share on Google+
SCJP Module-10 Question-10
Posted on: July 17, 2010 at 12:00 AM
The given example will test your understanding about the BufferedReader and FileReader classes and how to use this classes to read a file in Java.

Given a sample code for reading a specific line from file

import java.io.*;

public class ReadSpecificLine {

public static void main(String[] args) {
String line = "";
int lineNo;
try {
(1) Place code here fr = new FileReader("new.txt");
BufferedReader br = new (2) Place code here;
for (lineNo = 1; lineNo < 10; lineNo++) {
if (lineNo == 5) {
line = (3) Place code here;
} else
} catch (IOException e) {
System.out.println("Line: " + line);

Select the sequence of code from the given sentences for proper execution of above code.

(X) FileReader 
(Y) br.readLine()
(Z) BufferedReader(fr)


(A) 1-X, 2-Y, 3-Z
(B) 1-X, 2-Z , 3-Y 
(C) 1-Z, 2-X, 3-Y




Related Tags for SCJP Module-10 Question-10:

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 17, 2010

Recommend the tutorial

Advertisements Advertisements