Page 81 - CA_Blue( J )_Class9
P. 81
Ans.
a. Fractional Number float or double
b. A small Letter char
c. A sentence String
d. Long Integer long
11. Write down the data types in ascending order of size.
a. byte b. long
c. double d. short
Ans. byte < short < long < double
12. Name the operators listed below:
a. < b. ++
c. && d. ?:
Ans. a. < (Less than operator) b. ++ (Increment operator)
c. && (Logical AND operator) d. ?: (Conditional or Ternary operator)
13. What are the default values of the primitive data type int and float?
Ans. a. Default value of int is 0. b. Default value of float is 0.0f.
14. Identify the literals listed below: a. 0.5 b. ‘A’ c. false d. “a”
Ans. a. 0.5 – Real Literal b. ‘A’ – Character Literal
c. false – Boolean Literal d. “a” – String Literal
15. What is the range of uppercase and lowercase letters?
Ans. A–Z : 65 to 90 a–z : 97 to 122
16. Write a java statement to calculate and print the temperature in centigrade if in Fahrenheit it is 45 degree
( (F-32)*5/9 ).
Ans. System.out.println((45-32)/9.0*5.0);
17. Write the syntax to declare a double variable “d” containing 45.9;
Ans. double d=45.9;
18. What does “\n” means in terms of escape sequence?
Ans. “\n” means new line in terms of escape sequence.
21 st
D. Case Study. Century #Experiential Learning
Skills
John is developing a basic calculator in Java that can perform addition, subtraction, multiplication, and division. He
writes the following code to perform arithmetic operations:
class Calculator {
public static void main() {
int a = 10;
int b = 5;
int sum = a + b;
int difference = a - b;
int product = a * b;
int quotient = a / b;
int remainder = a % b;
System.out.println("Sum: " + sum);
System.out.println("Difference: " + difference);
System.out.println("Product: " + product);
System.out.println("Quotient: " + quotient);
System.out.println("Remainder: " + remainder);
Values and Types 79

