ICSE · Class 9 · Computer Applications
Class 9 Values and Data Types Mock Test (ICSE)
6 practice questions from Values and Data Types, in the style of your board paper, each with a worked answer and the marks for every step. Then take a full chapter test on paper, snap the pages and get every step marked.
Topics in Values and Data Types
- Character set and Unicode
- Escape sequences
- Tokens: keywords, identifiers, literals, operators, separators
- Primitive and non-primitive data types
- Variable declaration and initialisation
- Type conversion: implicit and explicit
Values and Data Types practice questions with answers
- Q1Multiple choice1 markWhat is the default initial value of a member variable of type boolean in Java?
- (a)true
- (b)null
- (c)0
- (d)false
Show answer and step marks
- Correct option: (d) false. Recall that the default value for a boolean instance or class variable in Java is false.+1
Answer: (d) - Q2Multiple choice1 markWhich of the following is a valid identifier in Java?
- (a)total_marks
- (b)2ndValue
- (c)int
- (d)total-marks
Show answer and step marks
- Correct option: (a) total_marks+1
Answer: (a) - Q3Short answer2 marksDistinguish between ASCII and Unicode character sets with respect to the storage size and the total number of characters represented.
Show answer and step marks
- Storage size: ASCII is a 7-bit code (stored in 1 byte; extended ASCII uses all 8 bits), whereas Unicode as used for Java's char takes 16 bits (2 bytes).+1
- Number of characters: ASCII represents characters ( in extended ASCII), whereas 16-bit Unicode represents characters; the full Unicode standard covers over a million characters by pairing two 16-bit units (surrogate pairs).+1
Answer: ASCII uses 7 bits (1 byte; 8 bits in extended ASCII) for characters ( extended); Unicode in Java uses 16 bits (2 bytes) for characters, extended beyond a million through surrogate pairs. - Q4Short answer2 marksExplain why the statement double y = x; compiles without any cast when x is an int variable, whereas the statement int z = (int) 7.9; needs an explicit cast.
Show answer and step marks
- Assigning an int to a double is an implicit (widening) conversion: every int value fits in a double without loss, so the compiler converts it automatically.+1
- Assigning a double to an int may lose the fractional part, so Java needs an explicit cast (int) to show the programmer accepts the truncation.+1
Answer: int to double is an implicit widening conversion that loses no information, while double to int can lose the fractional part, so it needs an explicit cast. - Q5Long answer4 marksA news portal's Java program prints the headline of a business report. The reporter must store the Greek capital letter omega (Ω, Unicode code point U+03A9) in a char variable, and the headline must also show the rupee symbol ₹. (a) State the number of bits that one char value occupies in Java. [1] (b) Write the Java statement that stores Ω in a char variable named omega, using a Unicode escape sequence. [1] (c) Explain why the older ASCII character set cannot represent the rupee symbol ₹. [2]
Show answer and step marks
- (a) Each char value occupies 16 bits (2 bytes), since Java uses 16-bit Unicode for char+1
- (b) char omega = '\u03A9';+1
- (c) ASCII uses 7 bits, giving only 128 codes that cover English letters, digits and common symbols+1
- (c) The code point of ₹ (U+20B9) lies outside the ASCII range, so ASCII has no code for it+1
Answer: (a) 16 bits (b) char omega = '\u03A9'; (c) ASCII has only 128 codes (7 bits), covering English letters, digits and common symbols; the rupee symbol ₹ (U+20B9) lies outside this range, so ASCII cannot store it. - Q6Long answer4 marksAnswer the following questions based on escape sequences in Java: (a) Explain the purpose of the escape sequences `` and `` with a suitable `System.out.println()` statement for each. (b) Predict the exact output of the following Java code snippet: System.out.println("Java" + "\"Class IX\"");
Show answer and step marks
- (a) `` (new line) moves the cursor to the beginning of the next line.+0.5
- (a) Example: System.out.println("Hello"); prints Hello and World on two separate lines.+0.5
- (a) `` (horizontal tab) moves the cursor to the next tab stop, leaving a gap.+0.5
- (a) Example: System.out.println("Roll"); prints Roll, a tab space, then Name on one line.+0.5
- (b) First line of output: Java, a tab space, then Programming (Java Programming).+1
- (b) Second line of output: "Class IX" (printed with the double quotes).+1
Answer: (a) `` moves the cursor to the next line, e.g. System.out.println("Hello"); prints Hello and World on separate lines. `` inserts a horizontal tab, e.g. System.out.println("Roll"); prints Roll, a tab space, then Name. (b) Output: Java Programming (a tab between Java and Programming) "Class IX" (printed with the double quotes)
Take a full Values and Data Types test
PrepitUp writes a fresh paper on this chapter at the length you pick. Write it on paper with a timer, photograph the pages, and see the marks for every step and what to practise next.
- 15 min10 marks
- 30 min20 marks
- 1.5 hr40 marks
- 3 hr80 marks
Get your Values and Data Types answers marked
Sign in, pick this chapter and a length, write the test on paper and get every step marked.
Sign in to take this test