-
What is the output of this program?
import java.io.*;
public class Chararrayinput_Example
{
public static void main(String[] args)
{
String object = "InterviewMania";
int len = object.length();
char array[] = new char[len];
object.getChars(0, len, array, 0);
CharArrayReader chararray = new CharArrayReader(array);
CharArrayReader chararray0 = new CharArrayReader(array, 1, 4);
int K;
int L;
try
{
while((K = chararray.read()) == (L = chararray0.read()))
{
System.out.print((char)K);
}
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
-
- Interview
- InterviewMania
- Mania
- All of these
- None of these
Correct Option: E
No output is printed. CharArrayReader object input1 contains string “InterviewMania” whereas object chararray contains string “nter”, when while((K=chararray.read())==(L=chararray.read())) is executed the starting character of each object is compared since they are unequal control comes out of loop and nothing is printed on the screen.