0

Java Basics

Description: Concept Based Questions
Number of Questions: 15
Created by:
Tags: Concept Based Questions Java Basics
Attempted 0/15 Correct 0 Score 0

The stream class can be categorised into how many groups depending upon the data on which they operate?

  1. 6

  2. 5

  3. 4

  4. 3

  5. 2


Correct Option: E
Explanation:

This is the correct answer. They are of two types: (i) Byte Stream for handling binary data. (ii) Character Stream for handling data such as sequence of characters.

Which of the following methods is/are defined in InputStream class of Bytes Stream?

  1. read(byte[ ] b)

  2. mark(int limit)

  3. read()

  4. Both (1) and (3)

  5. All of the above


Correct Option: E
Explanation:

As explained all of the methods are defined in the Input Stream class. So, this is the correct choice.

How many subclasses are there of the InputStream class?

  1. 9

  2. 8

  3. 7

  4. 6

  5. 5


Correct Option: B
Explanation:

This is the correct answer. There are 7 subclasses of the InputStream class. These are:

  1. FileInputStream for reading bytes from a file.
  2. ObjectInputStream for readin objects and primitive data types from input stream.
  3. SequenceInputStream for readin from a sequence of streams.
  4. ByteArrayInputStream for Stream that reads a byte array.
  5. pipedInputStream for reading from a piped stream.
  6. FilterInputStream for filtering input from Existing Stream.
  7. StringBufferInputStream for reading from a string.

How many subclasses of the OutputStream Class are present in Java?

  1. 9

  2. 6

  3. 5

  4. 8

  5. 7


Correct Option: C
Explanation:

There five subclasses of the OutputStream class are:

  1. FileOutputStream for writing bytes into file
  2. ObjectOutputStream for writing objects and primitive data types to output stream.
  3. ByteArrayOutputStream for output stream that writes byte into array.
  4. pipedOutputStream for writing into a piped stream.
  5. FilterOutputStream for filtering output into an existing stream. So, this is the correct answer.

Which of the following methods is/are defined in the OutputStream class?

  1. flush()

  2. write(byte[ ] b)

  3. write(byte[ ] b , int offset, int len)

  4. Both (1) and (3)

  5. All of the above


Correct Option: E
Explanation:

This is the correct answer because as explained, all of the given methods are defined in the OutputStream class.

Byte stream are defined by using _____ class hierarchy.

  1. 5

  2. 4

  3. 3

  4. 2

  5. 1


Correct Option: D
Explanation:

This is the correct answer. Byte stream can be defined by using two class hierarchies. These two classes are :

  1. InputStream
  2. OutputStream

Character Stream class is defined by using _____ class hierarchy.

  1. 7

  2. 5

  3. 2

  4. 4

  5. None of these


Correct Option: C
Explanation:

This is the correct answer. Character stream class is defined by using two class hierarchies. These classes are:

  1. Reader class
  2. Writer class. 

Which of the following methods is/are defined in the Reader class?

  1. skip(long)

  2. mark(int limit)

  3. reset()

  4. Both (1) and (3)

  5. All of the above


Correct Option: E
Explanation:

As explained, all of the methods are defined in the Reader class. So, this is the correct choice.

Which of the following is/are the subclasses of the OutputStream Class?

  1. ObjectOutputStream

  2. PipedOutputStream

  3. ByteOutputStream

  4. Both (1) and (2)

  5. All of the above


Correct Option: D
Explanation:

As explained, both options 1 and 2 are correct. So, this is the correct choice.

Which of the following is/are not the subclasses of the Writer class in Java?

  1. CharWriter

  2. StringWriter

  3. BufferedWriter

  4. Both (1) and (2)

  5. Both (1) and (3)


Correct Option: A
Explanation:

This is the correct answer. There is no Subclass named charWriter. The correct name is CharArrayWriter which is used for writing to a char array.

Which of the following is/are not the subclasses of the Reader class?

  1. StringReader

  2. PipeReader

  3. InputReader

  4. Both (1) and (2)

  5. Both (1) and (3)


Correct Option: C
Explanation:

There is no subclass of Reader class named InputReader. The correct name is InputStreamReader used for reading a character stream. So, this is the correct answer according to the question.

Which of the following methods is/are defined in the File class in Java?

  1. getPath()

  2. getName()

  3. length()

  4. Both (1) and (2)

  5. All of the above


Correct Option: E
Explanation:

As explained that all of the given methods are defined in the File class. So, this is the correct answer.

How many subclasses of the Reader Class are there in Java?

  1. 9

  2. 8

  3. 7

  4. 6

  5. 5


Correct Option: D
Explanation:

There are 6 subclasses of reader Class in Java. These are:

  1. BufferedReader for buffering other readers
  2. ChararrayReader for reading from char array
  3. FilterReader for reading filter streams
  4. InputStreamReader for reading a character stream
  5. PipedReader for reading from pipe
  6. StringReader for reading from a string So, this is the correct answer.

Which of the following is/are the subclasses of the InputStream Class?

  1. StrinBufferedInputStream

  2. FilterInputStream

  3. SequenceInputStream

  4. Both (2) and (3)

  5. All of the above


Correct Option: D
Explanation:

As explained, both the classes in option 2 and 3 are the only subclasses of the InputStream class. So, this is the correct answer.

How many subclasses of the Writer class are there in Java?

  1. 7

  2. 6

  3. 8

  4. 9

  5. 5


Correct Option: A
Explanation:

There are 7 subclasses of the Writer class in Java. These are:

  1. OutputStreamWrite for writing a character stream
  2. BufferedWriter for buffering other writers
  3. PrintWriter for writing formatted data
  4. PipedWriter for writing to a pipe
  5. CharArrayWriter for writing to a char array
  6. StringWriter for writing to a string
  7. FilterWriter for writing filtered streams. So, this is the correct answer.
- Hide questions