5 years ago in Java File Input Output

What is the output of this program?
  
import java.io.*;
class Chararrayinput {
public static void main(String[] args) {
String obj = "abcdef";
int length = obj.length();
char c[] = new char[length];
obj.getChars(0, length, c, 0);
CharArrayReader input1 = new CharArrayReader(c);
CharArrayReader input2 = new CharArrayReader(c, 0, 3);
int i;
try {
while ((i = input2.read()) != -1) {
System.out.print((char)i);
}
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

[A] abc
[B] abcd
[C] abcde
[D] abcdef
Loading...
Next Question

Overall Stats

Attempted 241
Correct 41
Incorrect 85
Viewed 115

Answers

Guest
Guest
Nevena Miuchin
Nevena Miuchin - 3 days ago

Nevena Miuchin from Ottawa, Canada is saying abc is correct answer

Vaibhav Bisht
Vaibhav Bisht - 1 month ago

Vaibhav Bisht from Dehradun, India is saying abcde is correct answer

Zo Go
Zo Go - 1 month ago

Zo Go from Casablanca, Morocco is saying abcdef is correct answer

Shahbaz khan
Shahbaz khan - 1 month ago

Shahbaz khan is saying abcdef is correct answer

GURU right tech pro
GURU right tech pro - 3 months ago

GURU right tech pro is saying abcde is correct answer

Related Questions

Which of these classes can return more than one character to be returned to input stream?

  • [A] BufferedReader
  • [B] Bufferedwriter
  • [C] PushbachReader
  • [D] CharArrayReader

Which of these class is used to read characters in a file?

  • [A] FileReader
  • [B] FileWriter
  • [C] FileInputStream
  • [D] InputStreamReader

Which of these interface is not a member of java.io package?

  • [A] DataInput
  • [B] ObjectInput
  • [C] ObjectFilter
  • [D] FileFilter