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.
Questions
Classes Http Servlet and Generic Servlet implement the ________ interface.
- Rmi
- Corba
- Jdbc
- Servlet
The life cycle of a Servlet is
- init, start, stop
- init, begin, stop, destroy
- init, service, destroy
- none of these
The method read (byte b[], int n,int m)
- reads m bytes into b starting from nth byte
- reads an array of bites
- reads n bytes into b starting from mth byte
- both (1) and (3)
To delete a file, we can use an instance of class file.
- Yes
- No
Which of the following stream classes is/are available in Java?
- Byte stream
- Character stream
- Both (1) and (2)
- None of these
Which of the following strings can be used as mode string(s) for creating a Random Access File object?
- �r�
- �w�
- �rw�
- both (1) and (3)
Which exception is thrown by the read() method of Input stream class?
- Exception
- Read Exception
- IO Exception
- None of these
If obj is an instance of Random Access File, how can we move the file pointer to the end of the file?
- obj.seek(obj.length())
- obj.seek(EOF())
- seek(obj.length())
- none of these
To read from file, we can use a version of read () that is defined in the class. Name it.
- File Reader
- File Input Stream
- File Read
- None of these
Which is/are the abstract superclass(es) for character streams in java.io?
- Reader
- Writer
- Both (1) and (2)
- None of these
Which of the following is the valid way to create Data Input Stream streams?
- new DataInputStream();
- new DataInputStream(“in.dat”,”r”);
- new DataInputStream(“in.dat”);
- new DataInputStream(new FileInputStream(“in.dat”)
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?
- Access File class
- Random Access File class
- Data in out stream
- None of these
Which of the following classes in java.io package define(s) a method to delete a file?
- Random Access File class
- File class
- Output class
- Both (1) and (3)
The two most common HTTP request types in servlets are
- take and give
- GET and POST
- init and start
- init and GET
Identify the abstraction that either produces or consumes information.
- Stream
- Package
- Class
- None of these
What is/are the disadvantage(s) of Variables and Arrays?
- Their storage is temporary.
- They hardly handle large amount of data.
- They have storage permanent.
- Both (1) and (2)
JAVA is a _______ language.
- Database
- COM
- Platform independent
- Platform dependent
Objects are the basic ________ in an object-oriented system.
- compile time entities
- runtime entities
- both (1) and (2)
- none of these
Which one of the following support(s) operator overloading?
- C
- C++
- JAVA
- C++ and JAVA
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?
- The package definition must come first
- Class should be private
- Method should be without void
- None of these
What is the maximum value of short data type?
- 127
- 32, 767
- 32, 768
- 128
Which class in the java.io package implements a random access file?
- Random File
- Random Access File
- Acess File
- None of these
Which of the following will be used to channel the output from one thread into the input of another?
- Strings
- Pipes
- Streams
- None of these
Which method(s) of buffered reader class is/are used to read string from the keyboard?
- read()
- readline()
- write()
- both (1) and (3)
Filter stream filters data as
- read from stream
- write to the stream
- both (1) and (2)
- none of these