Jpr - Qb Chapter 06

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Jpr - Qb Chapter 06 as PDF for free.

More details

  • Words: 704
  • Pages: 3
K K Wagh Polytechnic, Nashik – 3

Question Bank

: Java Programming (9113)

Class

: TYIF (IF/V/C)

Chapter No. 06 Streams and File IO Review Questions from previous MSBTE question papers: 1. 2. 3. 4. 5. 6. 7. 8.

9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20.

Describe RandomAccessFile with operations. What do you mean by a stream? State its applications. Differentiate between byte streams and character streams. How we will determine that file is a directory or not? Give different forms of write ( ) method of OutputStream class. Explain the differences between RandomAccessFile and FileReader. Describe the process of garbage collection. Describe following stream classes: a. ByteArrayInputStream b. PrintWriter c. BufferedReader d. FileOutputStream Illustrate various ways of taking input from the keyboard. What is serialization? Explain with suitable example. Explain various constructors of File class. Explain the hierarchy of stream classes in java.io package. Distinguish between OutputStream and Writer class. While reading a file, how do you determine that file pointer has reached the end of file? What are the advantages of random access file over sequential access file? Explain the meaning of various File class methods. How the read ( ) method can be used in different ways? Explain. What are the advantages provided by push back streams? Explain various operations performed using FileInputStream and FileOutputStream. What are the drawbacks of using the byte stream classes?

Programming Exercises: 1. 2. 3. 4. 5.

Copy the contents of one file into another and display the contents of both files. Accept the name of the file from command line and display its contents. Also check whether that file is existed or not? Convert the contents of a file into upper case. Counts the numbers of lines of a file. Accept the file name from user. Count total number of lower case characters of a file.

By Mr. Kute T. B. for (TYIF) 2008-2009

-1-

K K Wagh Polytechnic, Nashik – 3

6. 7.

Reverse the contents of the file using character streams. A file contains 100 different characters. Use random access file to print the alternate characters of that file. 8. Accept any character from user and insert that character at particular position inside the file. 9. Merge the contents of two file and display it. 10. Delete the last line of the file “first.txt” and rename it with “first.java”. Objective questions: 1.

Which of the following is a legal way to construct a RandomAccessFile? a) RandomAccessFile("data.txt", "r"); b) RandomAccessFile("r", "data.txt"); c) RandomAccessFile("data.txt", "read"); d) RandomAccessFile("read", "data.txt");

2.

What is the permanent effect on the file system of writing data to a new FileWriter("report.txt"), given the file “report.txt” already exists? a) The data is appended to the file b) The file is replaced with a new file c) An exception is raised as the file already exists d) The data is written to random locations within the file

3.

Which of the following correctly illustrate how an InputStreamReader can be created? a) new InputStreamReader(new FileInputStream("data")); b) new InputStreamReader(new FileReader("data")); c) new InputStreamReader(new BufferedReader("data")); d) new InputStreamReader("data"); e) new InputStreamReader(System.in);

4.

Which of the following is the correct syntax for suggesting that the JVM performs garbage collection? a) System.free(); b) System.setGarbageCollection(); c) System.out.gc(); d) System.gc();

5.

Which of the following will compile without error? a) File f = new File("/","autoexec.bat"); b) DataInputStream d = new DataInputStream(System.in); c) OutputStreamWriter o = new OutputStreamWriter(System.out); d) RandomAccessFile r = new RandomAccessFile("OutFile");

By Mr. Kute T. B. for (TYIF) 2008-2009

-2-

K K Wagh Polytechnic, Nashik – 3

6.

Which of the following can we perform using the File class? a) Change the current directory b) Return the name of the parent directory c) Delete a file d) Find if a file contains text or binary information

7.

The FileReader is subclass of which class? a) InputStreamReader b) BufferedReader c) OutputStreamReader d) CharArrayReader

8.

Which interface the ObjectInputStream implements? a) DataInput b) InputStream c) ObjectInput d) DataInputs

9.

Character stream counterpart of ByteArrayInputStream is ______? a) ByteArrayReader b) CharacterArrayReader c) CharArrayReader d) ArrayReader

10. What type of the value that readLine( ) returns ? a) String b) Char array c) Byte array d) String array

By Mr. Kute T. B. for (TYIF) 2008-2009

-3-

Related Documents

Jpr - Qb Chapter 06
June 2020 5
Jpr - Qb Chapter 05
June 2020 3
Jpr - Qb Chapter 02
June 2020 11
Jpr - Qb Chapter 01
June 2020 7
Jpr - Qb Chapter 04
June 2020 7
Jpr - Qb Chapter 03
June 2020 10