Given below is a class with the following specifications: class name : Number void Display(int n) - To extract and print each digit of the given number, from the last digit to the first digit, on separate lines. Example: n = 674 Output: 4 / 7 / 6 void Display() - To print numbers from 0.5 to 5.0 with an update of 0.5. Fill in the blanks of the given program with appropriate statements: class (i) __________ { void Display(int n) { while( (ii) __________ ) { int rem = (iii) __________ System.out.println(rem); n = (iv) __________ } } void Display() { for( (v) __________ ; x <= (vi) __________ ; x += 0.5) System.out.println(x); } }
Fill in blank (i): class __________
Topic: Naming a class
Try it
Pick an option and check your answer. The full worked answer is below either way.
Answer
(a) Number.
The specification states the class name exactly: Number. Java is case-sensitive, so number and NUMBER would be different identifiers, and NUM is not the given name at all. By convention class names begin with a capital letter, which is why Number is also the stylistically correct choice.
Number.