Page 139 - CA_Blue( J )_Class9
P. 139
6. nextDouble() is used to input ………………….
a. Real b. Character
c. Boolean d. Integer
7. next () is used to input ………………….
a. Integer b. Sentence
c. Boolean d. Word
8. br.readLine().charAt(0) is used to take ………………….
a. Word b. Sentence
c. Character d. Integer
9. import java.util.*; used for importing ………………….
a. InputStreamReader class b. Scanner class
c. Logical Error d. Java database connectivity classes
10. Documentation Comments begin with ………………….
a. // b. /*
c. /** d. """
Answers
1. b 2. c 3. b 4. b 5. a 6. a 7. d 8. c 9. b 10. c
B. Fill in the blanks.
1. ………………… can be detected during the process of debugging.
2. ………………… method inputs a line through Scanner class.
3. To input a ………………… through Scanner class, we use nextFloat().
4. ………………… is used to handle the exception that has been generated in the try block.
5. ………………… comments help to write more than one line.
6. The compiler will allow the program to execute if no ………………… error has occurred.
7. Default delimiter used in Scanner class is ………………….
8. Calendar is an abstract class of ………………… package.
9. Division operator used instead of multiplication is a ………………… error.
10. Initialisation is the process of taking value by………………….
Answers
1. Runtime error 2. nextLine() 3. float value 4. catch 5. Multiline 6. syntax
7. whitespace 8. java.util 9. Logical 10. direct method
C. Answer the following questions.
1. Write the different ways to give inputs in a Java Program.
Ans. The four different ways to input data in Java Programs are
a. initialisation b. through main method()
c. InputStreamReader d. Scanner class
2. Write a Java program to input the values of u (object's distance) and f (focal length of the lens) and calculate the value
of v, which represents the distance of the image from the lens. Use the formula: 1/v=1/u+1/f
Ans. import java.util.*;
class sphericalmirror
{
public static void main()
{
Scanner sc= new Scanner(System.in);
double v, u, f;
System.out.print("Enter distance of the object from the lens: ");
u = sc.nextDouble();
Input in Java 137

