Java Exercise Answers
PART A – Multiple Choice Answers
• 1. Primitive data types
• 2. Literal
• 3. Keyword
• 4. Char variable
• 5. ' '
• 6. String variable
• 7. 65 – 90
• 8. 12 / 3
• 9. string
• 10. double
• 11. boolean m = true;
Fill in the blanks
• 1. alphabet
• 2. ASCII
• 3. ASCII
• 4. token
• 5. literals
• 6. assignment
• 7. non■graphic characters
• 8. identifier
• 9. 4
• 10. homogeneous expression
Assertion and Reason
• Both Assertion and Reason are true and Reason explains the Assertion.
Application Based
• Answer: They are boolean.
Short Answers
• 1. Data type: It defines the type of data a variable can store.
• 2. Variable: A named memory location used to store data. Example: int age = 15;
• 3. Constant: A value that does not change during program execution.
• 4. Two kinds of data types: Primitive and Non■primitive.
• 5. Token: Smallest unit of a Java program. Types: keyword, identifier, literal, operator,
separator.
• 6. Variable rules: start with letter/_; no spaces; cannot start with number; no keywords.
• 7. Type casting: converting one data type to another.
• 8a. double pi = 3.142857;
• 8b. double root3 = 1.732;
• 10a. int
• 10b. long
• 10c. float or double
• 10d. char
• 11. Boolean stores true or false.
• 12. Primitive data types are basic built■in types like int and float.
• 13. Data types help store correct data and save memory.
• 14a. Implicit conversion: automatic conversion.
• 14b. Explicit conversion: manual casting.
• 15. Coercion: automatic conversion by compiler.
• 16. Type conversion: changing one data type to another.
• 17. Static declaration: memory before execution; Dynamic: memory during execution.
• 18. Non■primitive types: String, Array, Class.
Return Data Types
• (i) double
• (ii) double
Resultant Data Types
• (a) int
• (b) double
• (c) float
• (d) float
• (e) double
• (f) float