A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

61. What is the output of this program?
    import java.io.*;
    class files 
    {
        public static void main(String args[]) 
        {
            File obj = new File("/java/system");
            System.out.print(obj.canWrite());
            System.out.print(" " + obj.canRead());
        }
    }
a. true false
b. false true
c. true true
d. false false
View Answer Report Discuss Too Difficult! Search Google
Answer: (d).false false

62. What is the output of this program?
    import java.io.*;
    class files 
    {
        public static void main(String args[]) 
        {
            File obj = new File("/java/system");
            System.out.print(obj.getParent());
            System.out.print(" " + obj.isFile());
        }
    }
a. java true
b. java false
c. \java false
d. \java true
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).\java false

63. Which of these class is used to read and write bytes in a file?
a. FileReader
b. FileWriter
c. FileInputStream
d. InputStreamReader
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).FileInputStream

64. Which of these method of InputStream is used to read integer representation of next available byte input?
a. read()
b. scanf()
c. get()
d. getInteger()
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).read()

65. Which of these data type is returned by every method of OutputStream?
a. int
b. float
c. byte
d. none of the mentioned
View Answer Report Discuss Too Difficult! Search Google
Answer: (d).none of the mentioned

66. Which of these is a method to clear all the data present in output buffers?
a. clear()
b. flush()
c. fflush()
d. close()
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).flush()

67. 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()
View Answer Report Discuss Too Difficult! Search Google
Answer: (b).print() and write()

68. What is the output of this 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
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).prints number of bytes in file

69. What is the output of this 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
View Answer Report Discuss Too Difficult! Search Google
Answer: (a).abc

70. Which of these stream contains the classes which can work on character stream?
a. InputStream
b. OutputStream
c. Character Stream
d. All of the mentioned
View Answer Report Discuss Too Difficult! Search Google
Answer: (c).Character Stream