Given that course.txt is accessible and contains:
Course : : Java
and given the code fragment:
public static void main (String[ ] args) {
int i;
char c;
try (FileInputStream fis = new FileInputStream (“course.txt”);
InputStreamReader isr = new InputStreamReader(fis);) {
while (isr.ready()) { //line n1
isr.skip(2);
i = isr.read ();
c = (char) i;
System.out.print(c);
}
} catch (Exception e) {
e.printStackTrace();
}
}
What is the result?
A.
ur :: va
B.
ueJa
C.
The program prints nothing.
D.
A compilation error occurs at line n1.
Should be B.
Reading question the answer should be A, but I am unable to run this code without Exception. help.
answer is B. ueJa
The file only contains one line Course::Java.
1 time
isr.skip(2); Co-u
i = isr.read (); u
2 time
isr.skip(2); rs-e
i = isr.read (); e
3 time
isr.skip(2); ::-J
i = isr.read (); J
i = isr.read (); e
4 time
isr.skip(2); av-a
i = isr.read (); a
thank you
B
B is correct
B
B.
ueJa