Curriculum
Course: Learn Java Programming
time left:
:
:
Login

Curriculum

Learn Java Programming

Quiz

Working With Inputs in Java

Submit quiz
Once you submit, you will no longer be able to change your answers. Are you sure you want to submit the quiz?
1.
Which method would you use to read a single word from the console input?
nextLine()
next()
read()
getString()
2.
Which of these is not a method of the Scanner class?
nextInt()
readLine()
nextDouble()
next()
3.
To use the BufferedReader class, which package needs to be imported?
java.util
java.io
java.lang
java.buffer
4.
What is the use of BufferedReader in Java?
To read single characters
To read a line of text
To parse primitive data types
To read binary data
5.
Which import statement is used for the Scanner class in Java?
import java.io.Scanner;
import java.util.Scanner;
import java.lang.Scanner;
import java.util.Input;
6.
What will happen if you try to use nextInt() to read an input when the next token is not an integer?
The Scanner class will automatically convert the input to an integer.
The program will throw a NoSuchElementException
The program will throw an InputMismatchException
The Scanner class will return 0 as the default value.
7.
What does the Scanner class use as its default delimiter?
Comma (,)
Space( ' ' )
Semicolon (;)
Period (.)
8.
When using a Scanner object, which method checks if the next input token can be interpreted as a valid double value without actually reading it?
hasDouble()
nextDouble()
hasNextDouble()
isDouble()
9.
Which one of these is a way to read input from the command line arguments?
Scanner
BufferedReader
System.in
args parameter in the main method
10.
To change the current delimiter pattern that a Scanner uses, which method should be invoked?
setDelimiter(String delimiter)
useDelimiter(String delimiter)
changeDelimiter(String delimiter)
delimiter(String delimiter)
11.
If you want to read an integer value from the console, which Scanner method would you use?
getInt()
readInt()
nextInt()
parseInteger()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11