476). Which of these classes is used for input and output operation when working with bytes?

[A]InputStream
[B]Reader
[C]Writer
[D] All of the mentioned

Show Answer

479). Which of these data type is returned by every method of OutputStream?

[A]int
[B]float
[C]byte
[D]none of the mentioned

Show Answer

481). Which of these method(s) is/are used for writing bytes to an outputstream?

[A]put()
[B]print() and write()
[C]printf()
[D]write() and read()

Show Answer

482). What will be the output of the following Java program? (Note: inputoutput.java is stored in the disk.)
    import java.io.*;
    class filesinputoutput 
    {
        public static void main(String args[]) 
        {
            InputStream obj = new FileInputStream("inputoutput.java");
            System.out.print(obj.available());
        }
    }

[A]true
[B]false
[C] prints number of bytes in file
[D]prints number of characters in the file

Show Answer

483). What will be the output of the following Java program?
    import java.io.*;
    public class filesinputoutput 
    {
    	public static void main(String[] args) 
        {
 	   String obj  = "abc";
           byte b[] = obj.getBytes();
           ByteArrayInputStream obj1 = new ByteArrayInputStream(b);
           for (int i = 0; i < 2; ++ i) 
           {
               int c;
               while ((c = obj1.read()) != -1) 
               {
            	   if(i == 0) 
                   {
            	       System.out.print((char)c); 
            	   }
               }
           }
        }
    }

[A]abc
[B]ABC
[C]ab
[D]AB

Show Answer

484). What will be the output of the following Java program?
    import java.io.*;
    public class filesinputoutput 
    {
    	public static void main(String[] args) 
        {
 	   String obj  = "abc";
           byte b[] = obj.getBytes();
           ByteArrayInputStream obj1 = new ByteArrayInputStream(b);
           for (int i = 0; i < 2; ++ i) 
           {
               int c;
               while ((c = obj1.read()) != -1) 
               {
            	   if (i == 0) 
                   {
                       System.out.print(Character.toUpperCase((char)c)); 
            	   }
               }
           }
        }
    }

[A]abc
[B]ABC
[C]ab
[D]AB

Show Answer

485). What will be the output of the following Java program?
   import java.io.*;
    public class filesinputoutput 
    {
    	public static void main(String[] args) 
        {
 	   String obj  = "abc";
           byte b[] = obj.getBytes();
           ByteArrayInputStream obj1 = new ByteArrayInputStream(b);
           for (int i = 0; i < 2; ++ i) 
           {
               int c;
               while ((c = obj1.read()) != -1) 
               {
            	   if (i == 0) 
                   {
                       System.out.print(Character.toUpperCase((char)c));
                       obj2.write(1); 
            	   }
               }
               System.out.print(obj2);
           }
        }
    }

[A]AaBaCa
[B]ABCaaa
[C]AaaBaaCaa
[D]AaBaaCaaa

Show Answer