Java I/O and Servlets

Test your knowledge of Java I/O operations including streams, file handling, and RandomAccessFile, plus basic servlet concepts and Java language fundamentals.

25 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Classes Http Servlet and Generic Servlet implement the ________ interface.

  1. Rmi
  2. Corba
  3. Jdbc
  4. Servlet
Question 2 Multiple Choice (Single Answer)

The life cycle of a Servlet is

  1. init, start, stop
  2. init, begin, stop, destroy
  3. init, service, destroy
  4. none of these
Question 3 Multiple Choice (Single Answer)

The method read (byte b[], int n,int m)

  1. reads m bytes into b starting from nth byte
  2. reads an array of bites
  3. reads n bytes into b starting from mth byte
  4. both (1) and (3)
Question 4 Multiple Choice (Single Answer)

To delete a file, we can use an instance of class file.

  1. Yes
  2. No
Question 5 Multiple Choice (Single Answer)

Which of the following stream classes is/are available in Java?

  1. Byte stream
  2. Character stream
  3. Both (1) and (2)
  4. None of these
Question 6 Multiple Choice (Single Answer)

Which of the following strings can be used as mode string(s) for creating a Random Access File object?

  1. �r�
  2. �w�
  3. �rw�
  4. both (1) and (3)
Question 7 Multiple Choice (Single Answer)

Which exception is thrown by the read() method of Input stream class?

  1. Exception
  2. Read Exception
  3. IO Exception
  4. None of these
Question 8 Multiple Choice (Single Answer)

If obj is an instance of Random Access File, how can we move the file pointer to the end of the file?

  1. obj.seek(obj.length())
  2. obj.seek(EOF())
  3. seek(obj.length())
  4. none of these
Question 9 Multiple Choice (Single Answer)

To read from file, we can use a version of read () that is defined in the class. Name it.

  1. File Reader
  2. File Input Stream
  3. File Read
  4. None of these
Question 10 Multiple Choice (Single Answer)

Which is/are the abstract superclass(es) for character streams in java.io?

  1. Reader
  2. Writer
  3. Both (1) and (2)
  4. None of these
Question 11 Multiple Choice (Single Answer)

Which of the following is the valid way to create Data Input Stream streams?

  1. new DataInputStream();
  2. new DataInputStream(“in.dat”,”r”);
  3. new DataInputStream(“in.dat”);
  4. new DataInputStream(new FileInputStream(“in.dat”)
Question 12 Multiple Choice (Single Answer)

There are three classes that implement the Data Input and Data Output interfaces. Two of them are: Data Input Stream and Data output stream. Which is the third one?

  1. Access File class
  2. Random Access File class
  3. Data in out stream
  4. None of these
Question 13 Multiple Choice (Single Answer)

Which of the following classes in java.io package define(s) a method to delete a file?

  1. Random Access File class
  2. File class
  3. Output class
  4. Both (1) and (3)
Question 14 Multiple Choice (Single Answer)

The two most common HTTP request types in servlets are

  1. take and give
  2. GET and POST
  3. init and start
  4. init and GET
Question 15 Multiple Choice (Single Answer)

Identify the abstraction that either produces or consumes information.

  1. Stream
  2. Package
  3. Class
  4. None of these
Question 16 Multiple Choice (Single Answer)

What is/are the disadvantage(s) of Variables and Arrays?

  1. Their storage is temporary.
  2. They hardly handle large amount of data.
  3. They have storage permanent.
  4. Both (1) and (2)
Question 17 Multiple Choice (Single Answer)

JAVA is a _______ language.

  1. Database
  2. COM
  3. Platform independent
  4. Platform dependent
Question 18 Multiple Choice (Single Answer)

Objects are the basic ________ in an object-oriented system.

  1. compile time entities
  2. runtime entities
  3. both (1) and (2)
  4. none of these
Question 19 Multiple Choice (Single Answer)

Which one of the following support(s) operator overloading?

  1. C
  2. C++
  3. JAVA
  4. C++ and JAVA
Question 20 Multiple Choice (Single Answer)

Consider the following class file:
import java.awt.;
import java.io.
;
package student;
class test
{
void display()
{
System.out.print(“welcome”);
}
}
What type of error will occur?

  1. The package definition must come first
  2. Class should be private
  3. Method should be without void
  4. None of these
Question 21 Multiple Choice (Single Answer)

What is the maximum value of short data type?

  1. 127
  2. 32, 767
  3. 32, 768
  4. 128
Question 22 Multiple Choice (Single Answer)

Which class in the java.io package implements a random access file?

  1. Random File
  2. Random Access File
  3. Acess File
  4. None of these
Question 23 Multiple Choice (Single Answer)

Which of the following will be used to channel the output from one thread into the input of another?

  1. Strings
  2. Pipes
  3. Streams
  4. None of these
Question 24 Multiple Choice (Single Answer)

Which method(s) of buffered reader class is/are used to read string from the keyboard?

  1. read()
  2. readline()
  3. write()
  4. both (1) and (3)
Question 25 Multiple Choice (Single Answer)

Filter stream filters data as

  1. read from stream
  2. write to the stream
  3. both (1) and (2)
  4. none of these