Sail E0 Webinar

MCQs

Total Questions : 51 | Page 1 of 6 pages
Question 1. System class is defined in .................
  1.    java.util package
  2.    java.lang package
  3.    java.io package
  4.    java.awt package
  5.    None of these
 Discuss Question
Answer: Option B. -> java.lang package
Question 2. Which of these classes defined in java.io and used for file-handling are abstract?
A. InputStream
B. PrintStream
C. Reader
D. FileInputStream
E. FileWriter
  1.    Only A
  2.    Only C
  3.    A and C
  4.    B and D
  5.    A, B and E
 Discuss Question
Answer: Option C. -> A and C
Question 3. Try{
File f = new File("a.txt");
}catch(Exception e){
}catch(IOException io){
}
Is this code create new file name a.txt ?
  1.    true
  2.    false
  3.    Compilation Error
  4.    None of these
 Discuss Question
Answer: Option C. -> Compilation Error
Question 4. When comparing java.io.BufferedWriter and java.io.FileWriter, which capability exist as a method in only one of two ?
  1.    closing the stream
  2.    flushing the stream
  3.    writting to the stream
  4.    writting a line separator to the stream
  5.    None of these
 Discuss Question
Answer: Option D. -> writting a line separator to the stream
Question 5.


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.getName());
}
}
  1.    java
  2.    system
  3.    java/system
  4.    /java/system
 Discuss Question
Answer: Option B. -> system

obj.getName() returns the name of the file.


Question 6.

Which of these is method for testing whether the specified element is a file or a directory?


  1.    IsFile()
  2.    isFile()
  3.    Isfile()
  4.    isfile()
 Discuss Question
Answer: Option B. -> isFile()

isFile() returns true if called on a file and returns false when called on a directory.


Question 7.

Which of these class is not related to input and output stream in terms of functioning?


  1.    File
  2.    Writer
  3.    InputStream
  4.    Reader
 Discuss Question
Answer: Option A. -> File

A File describes properties of a file, a File object is used to obtain or manipulate 

the information associated with a disk file, such as the permissions, time date, 

and directories path, and to navigate subdirectories.


Question 8.

Which of these is specified by a File object?


  1.    a file in disk
  2.    directory path
  3.    directory in disk
  4.    None of the mentioned
 Discuss Question
Answer: Option C. -> directory in disk


Question 9.

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


  1.    DataInput
  2.    ObjectInput
  3.    ObjectFilter
  4.    FileFilter
 Discuss Question
Answer: Option C. -> ObjectFilter


Question 10.

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


  1.    String
  2.    StringReader
  3.    Writer
  4.    File
 Discuss Question
Answer: Option A. -> String


Latest Videos

Latest Test Papers