0% found this document useful (0 votes)
7 views3 pages

Input in Java

The document contains a series of multiple-choice questions related to Java programming concepts, including error types, Scanner methods, and package usage. Each question is followed by the correct answer, providing a quick reference for learners. Key topics include syntax errors, input methods, and data type conversions.

Uploaded by

sahapriyanshu56
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Input in Java

The document contains a series of multiple-choice questions related to Java programming concepts, including error types, Scanner methods, and package usage. Each question is followed by the correct answer, providing a quick reference for learners. Key topics include syntax errors, input methods, and data type conversions.

Uploaded by

sahapriyanshu56
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Input in Java

Chapter 6

Tick () the correct option.

1. Which among the following is not valid error in Java?

a. Syntax errors b. Logical errors c. Run-time errors d. Technical errors

Ans. d. Technical errors

2. Which among the following Scanner methods allows us to input a number with a decimal point?

a. nextInt() b. nextFloat() c. nextDecimal() d. nextPoint()

Ans. b. nextFloat()

3. The output in BlueJ occurs in which window?

a. Console window b. Terminal window c. Both a and b d. None of these

Ans. b. Terminal window

4. The input in BlueJ occurs in which window?

a. Console window b. Terminal window c. Both a and b d. None of these

Ans. b. Terminal window

5. Assigning value to a variable during declaration is called _________?

a. Declaration b. Assignment c. Initialisation d. None of these

Ans. c. Initialisation

6. Which among the following is used to represent single-line comment?

a. // b. /* c. \\ d. <!—

Ans. a. //

7. Which among the following is a logical error?

a. Missing semicolon b. Mismatched braces in classes and methods.

c. Misspelled keywords and identifiers. d. Addition is required but subtraction is performed.

Ans. d. Addition is required but subtraction is performed.


8. Which among the following represents a syntax error?

a. Dividing an integer by zero.

b. Accessing an element that is out of bounds of an array.

c. Trying to store a value which is incompatible to a certain data-type.

d. Missing semicolon

Ans. d. Missing semicolon

9. If the data that is to take part in a calculation in a method is fixed, which form of input is necessary?

a. Initialisation b. Parameterised input c. Scanner input d. None of these

Ans. a. Initialisation

10. In case you need to give a proper message (prompt string) before taking an input from the user,

which would be the most preferable method?

a. Initialisation b. Parameterised input c. Scanner input d. None of these

Ans. c. Scanner input

11. a package needed to import scanner class


a. java.io, b. java.util c. java.lang d. java.net

12. a method that accepts a character through scanner object


a. charAt() b. CharAt() c. Charat() d. CharAT()

13. a package needed to import Stream Reader Class


a. java.io b. java.util c. java.lang d. java.net

14. a method to accept an exponential value through scanner object


a. next() b. nextInt() c. nextDouble() d. Nextdouble()

15. a method that accepts an integer token through scanner object


a. next() b. nextInt() c. nextDouble() d. Nextdouble()

16. In Java, a library of classes is called _______

a. a folder b. a package c. a directory d. an application

17. Name the type of error in the statement given below: double x: y:z:

a. Logical error b. Syntax error c. Runtime error d. No error


18. It is a term of converting one data type into another?

a. Comment b. Block c. Variable d. Type casting.

19. Java packages can be stored in compressed files called.

a. JAR files b. JVM files c. Java files d. JRE files.

20. A package is a :

a. collection of data b. collection of functions c. collection of classes d. a nested class

21. The parseInt() function is a member of :

a. Integer wrapper class b. Character wrapper class c. Boolean wrapper class d. None

22. The Scanner class belongs to :

a. awt package b. net package c. graphics package d. util package

You might also like