adplus-dvertising
frame-decoration

Question

What is the output of this program?
    import java.io.*;
    class Chararrayinput 
    {
        public static void main(String[] args) 
        {
     String obj  = "abcdefgh";
            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, 1, 4);
            int i;
            int j;
            try 
            {
  while ((i = input1.read()) == (j = input2.read())) 
                {
                    System.out.print((char)i);
                }
            } 
            catch (IOException e) 
            {
         // TODO Auto-generated catch block
                e.printStackTrace();
     }
 }
    }

a.

abc

b.

abcd

c.

abcde

d.

None of the mentioned

Posted under Java Programming

Answer: (d).None of the mentioned

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the output of this program?

Similar Questions

Discover Related MCQs

Q. Which of the following is not a segment of memory in java?

Q. Does code Segment loads the java code?

Q. What is JVM?

Q. Which one of the following is a class loader?

Q. Which class loader loads jar files from JDK directory?

Q. Which of the following is not a memory classification in java?

Q. What is the Java 8 update of PermGen?

Q. Classes and Methods are stored in which space?

Q. Where is String Pool stored?

Q. The same import package/class be called twice in java?

Q. Which of these exceptions handles the situations when an illegal argument is used to invoke a method?

Q. Which of these exceptions will be thrown if we declare an array with negative size?

Q. Which of these packages contain all the Java’s built in exceptions?

Q. Which of these exceptions will be thrown if we use null reference for an arithmetic operation?

Q. Which of these class is used to create user defined exception?

Q. Which of these class provides various types of rounding functions?

Q. Which of these methods return a smallest whole number greater than or equal to variable X?

Q. Which of these method returns a largest whole number less than or equal to variable X?

Q. Which of function return absolute value of a variable?

Q. Which of these methods of Byte wrapper can be used to obtain Byte object from a string?