facebook twitter pinterest google plus Youtube

Java BufferedReader Test
Free Online Java Programming Tests
Java Language Programming

Test yourself on Java Programming BufferedReader - Importing the java.io package to get an input using BufferedReader in the program.

10 Question Multiple Choice Quiz with Answers and Answer Explanations

1) What is the Java package that should be imported in the Java program so that BufferedReader can be used?
a) javax.swing package.
b) java.io package.
c) javax.io package.
d) java.swing package.

2) Aside from the BufferedReader class that is inside the java.io package, what other class that is needed in the java program so that BufferedReader will function properly?
a) InputStreamReader
b) IOExeption
c) System
d) All of the above

3) What is the variable name in the given BufferedReader declaration? BufferedReader dataInput = new BufferedReader(new InputStreamReader(System.in) );
a) InputStreamReader
b) BufferedReader
c) System.in
d) dataInput

4) In the given statement,  name = dataInput.readLine(); , what should be the variable declaration so that variable name holds a string values?
a) int name=””;
b) float name=””;
c) String name=””;
d) char name=””;

5) What is the method needed in the program so that a declared BufferedReader can accept an input from the user?
a) readLine()
b) readline()
c) readLn()
d) readln()

6) What is the program block needed so that possible exceptions will be caught in the program?
a) try-exception block
b) catch-try block
c) try-catch block
d) throws-exception block

7) What should be added after the statement public static void main(String[]args) if the java program used BufferedReader but does not have try-catch block?
a) throws OIException
b) throw OIException
c) throw IOException
d) throws IOException

8) What is the shortcut import declaration so that the BufferedReader, InputStreamReader and IOExceptions classes will be included in an import declaration in the program?
a) javax.io.*;
b) java.io.*;
c) javax.swing.*;
d) java.swing.*;

9) What is the java keyword needed in declaring a BufferedReader class in a java program?
a) The new keyword.
b) The System keyword.
c) The BufferedReader keyword.
d) The InputStreamReader keyword.

10) Which of the following is a correct java statement used to get an input from the user?
a) String name = datainput.readLine();
b) string 1name = datainput.readLine();
c) String name = datainput.readline();
d) String 1name = datainput.readline();