1. ______method of File class tests whether the file denoted by this abstract pathname is a normal file.
Ans: isFile()
2. The Reader/ Writer class hierarchy is______
Ans: Character-oriented
3. Return type of ensureOpen() method in BufferedWriter class is void
Ans: true
4. How many parameter min() method takes in BufferedWriter class?
Ans: 2
5. FileReader is meant for reading streams of characters. For reading streams of raw bytes, use ____
Ans: FileInputStream
6. What class should be used to buffer the characters sent to a FileWriter stream?
Ans: BufferedWriter
7. Writer class is designed specifically for______characters
Ans: Unicode
8. In which Package Reader classes are defined?
Ans: java.io
9. Which of these is a method to clear all the data present in output buffers?
Ans: flush()
10. BufferedInputStream and BufferedOutputStream are the sub classes of_____
Ans: FilterInputStream & FilterOutputStream
11. Which of these method of InputStream is used to read integer representation of next available byte input?
Ans: read()
12. Which Exception is thrown by methods of Reader class?
Ans: IOException
13. When a file is opened for appending where does write() put next text?
Ans: At the end of the file
14. Which of these exception is thrown by close() and read() methods?
Ans: IOException
15. Reader class is for reading Character streams
Ans: true
16. What will be the output of the below code
import java.io.*;
public class fileinputoutput{
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);
}
}
}
Ans: AaBaaCaaa
17. How many parameter write() method takes in BufferedWriter class?
Ans: 1 or 3
18. _____method creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist.
Ans: createNewFile()
19. What class does readLine() belong to?
Ans: BufferedReader
20. Should FileReader be used to read a Java bytecode (*.class) file?
Ans: No---the bytes in bytecode files are not intended to be interpreted as characters
21. _____metho of File class creates the directory named by this Abstract pathname
Ans: mkdir()
22. File class implements the interfaces
Ans: Comparable
23. What file method creates a new disk directory
Ans: mkdir()
24. To set the write permission only for the owner of the file use the ____method of the File class
Ans: setWritable(true,true)
25. Which operation is usually more reliable: input or output?
Ans: Output
26. _____method creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist
Ans: createNewFile()
27. To set the write permission only for all the users of the file use the_____method of the File class
Ans: setWritable(true,false)
28. Which package holds the file class?
Ans: java.io
29. Which of these is used to perform all input and output operations in java?
Ans: streams
30. _____method of File class enables read permission for all the users of the file
Ans: setReadable(true,false)
31. What method of file is used to test if a file or directory exists?
Ans: exists()
32. Which of the following is used in a C-style input loop?
Ans: while((line=source.readLine())!=null)
33. _____method of File class is used to rename the file
Ans: renameTo(File dest)
34. If deleting a directory using File class delete method the Directory must be empty
Ans: True
35. _____method of File class enables read permission for only owner of the file
Ans: setReadable(true,true)
36. ______method of File class returns the time that the file denoted by this abstract pathname was last modified
Ans: lastModified()
37.______method of File class tests whether the file named by this abstract pathname is a hidden file
Ans: isHidden()
38.______method of File class is used to retrieve the Absolute path of the file
Ans: getAbsolutePath()
39. Which of these is a method to clear all the data present in output buffers?
Ans: flush()
40. BufferedInputStream and BufferedOutputStream are the sub-classes of_______
Ans: FilterInputStream and FilterOutputStream
41. Which of these method of InputStream is used to read integer representation of next available byte input?
Ans: read()
42. Which Exception is thrown by methods of Reader class?
Ans: IOException
43. When a file is opened for appending where does the write() put new text?
Ans: At the end of the file
44. How many parameter write() method takes in BufferedWriter Class?
Ans: 1 or 3
45. _____method creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist.
Ans: createNewFile()
46. What is the return type of skip() method in BufferedReader class?
Ans: long
47. For characters from the English (Roman) alphabet, how many bytes are used per character in the program and how many are used on a disk file?
Ans: Program: 2 bytes Disk file: 1 byte
48. What does the following constructor do: FileWriter fw=new FileWriter("myfile.txt");
Ans: Any previous myfile.txt in the current directory will be deleted and the new one will be created
49. It is possible to use the File class to list the contents of the current working directory
Ans: True
50. The decoding layer of InputStream transforms bytes to chars according to an _______standard
Ans: encoding
51. What is the return type of min() method in BufferedWriter class?
Ans: int
52. _______method of File class tests whether the file denoted by this abstract pathname is a Directory
Ans: isDirectory()
53. Reader class is designed specifically for Unicode characters
Ans: true
54. Which of these is a type of stream in Java?
Ans: Byte stream
55. What is the data type of parameter passed in min() method of BufferedWriter class?
Ans: (int, int)
56. What is the name of the abstract base class for streams dealing with general purpose input
Ans: InputStream
Ans: isFile()
2. The Reader/ Writer class hierarchy is______
Ans: Character-oriented
3. Return type of ensureOpen() method in BufferedWriter class is void
Ans: true
4. How many parameter min() method takes in BufferedWriter class?
Ans: 2
5. FileReader is meant for reading streams of characters. For reading streams of raw bytes, use ____
Ans: FileInputStream
6. What class should be used to buffer the characters sent to a FileWriter stream?
Ans: BufferedWriter
7. Writer class is designed specifically for______characters
Ans: Unicode
8. In which Package Reader classes are defined?
Ans: java.io
9. Which of these is a method to clear all the data present in output buffers?
Ans: flush()
10. BufferedInputStream and BufferedOutputStream are the sub classes of_____
Ans: FilterInputStream & FilterOutputStream
11. Which of these method of InputStream is used to read integer representation of next available byte input?
Ans: read()
12. Which Exception is thrown by methods of Reader class?
Ans: IOException
13. When a file is opened for appending where does write() put next text?
Ans: At the end of the file
14. Which of these exception is thrown by close() and read() methods?
Ans: IOException
15. Reader class is for reading Character streams
Ans: true
16. What will be the output of the below code
import java.io.*;
public class fileinputoutput{
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);
}
}
}
Ans: AaBaaCaaa
17. How many parameter write() method takes in BufferedWriter class?
Ans: 1 or 3
18. _____method creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist.
Ans: createNewFile()
19. What class does readLine() belong to?
Ans: BufferedReader
20. Should FileReader be used to read a Java bytecode (*.class) file?
Ans: No---the bytes in bytecode files are not intended to be interpreted as characters
21. _____metho of File class creates the directory named by this Abstract pathname
Ans: mkdir()
22. File class implements the interfaces
Ans: Comparable
23. What file method creates a new disk directory
Ans: mkdir()
24. To set the write permission only for the owner of the file use the ____method of the File class
Ans: setWritable(true,true)
25. Which operation is usually more reliable: input or output?
Ans: Output
26. _____method creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist
Ans: createNewFile()
27. To set the write permission only for all the users of the file use the_____method of the File class
Ans: setWritable(true,false)
28. Which package holds the file class?
Ans: java.io
29. Which of these is used to perform all input and output operations in java?
Ans: streams
30. _____method of File class enables read permission for all the users of the file
Ans: setReadable(true,false)
31. What method of file is used to test if a file or directory exists?
Ans: exists()
32. Which of the following is used in a C-style input loop?
Ans: while((line=source.readLine())!=null)
33. _____method of File class is used to rename the file
Ans: renameTo(File dest)
34. If deleting a directory using File class delete method the Directory must be empty
Ans: True
35. _____method of File class enables read permission for only owner of the file
Ans: setReadable(true,true)
36. ______method of File class returns the time that the file denoted by this abstract pathname was last modified
Ans: lastModified()
37.______method of File class tests whether the file named by this abstract pathname is a hidden file
Ans: isHidden()
38.______method of File class is used to retrieve the Absolute path of the file
Ans: getAbsolutePath()
39. Which of these is a method to clear all the data present in output buffers?
Ans: flush()
40. BufferedInputStream and BufferedOutputStream are the sub-classes of_______
Ans: FilterInputStream and FilterOutputStream
41. Which of these method of InputStream is used to read integer representation of next available byte input?
Ans: read()
42. Which Exception is thrown by methods of Reader class?
Ans: IOException
43. When a file is opened for appending where does the write() put new text?
Ans: At the end of the file
44. How many parameter write() method takes in BufferedWriter Class?
Ans: 1 or 3
45. _____method creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist.
Ans: createNewFile()
46. What is the return type of skip() method in BufferedReader class?
Ans: long
47. For characters from the English (Roman) alphabet, how many bytes are used per character in the program and how many are used on a disk file?
Ans: Program: 2 bytes Disk file: 1 byte
48. What does the following constructor do: FileWriter fw=new FileWriter("myfile.txt");
Ans: Any previous myfile.txt in the current directory will be deleted and the new one will be created
49. It is possible to use the File class to list the contents of the current working directory
Ans: True
50. The decoding layer of InputStream transforms bytes to chars according to an _______standard
Ans: encoding
51. What is the return type of min() method in BufferedWriter class?
Ans: int
52. _______method of File class tests whether the file denoted by this abstract pathname is a Directory
Ans: isDirectory()
53. Reader class is designed specifically for Unicode characters
Ans: true
54. Which of these is a type of stream in Java?
Ans: Byte stream
55. What is the data type of parameter passed in min() method of BufferedWriter class?
Ans: (int, int)
56. What is the name of the abstract base class for streams dealing with general purpose input
Ans: InputStream
This comment has been removed by the author.
ReplyDelete