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

  1. Q1Multiple choice1 mark
    What is the default initial value of a member variable of type boolean in Java?
    1. (a)true
    2. (b)null
    3. (c)0
    4. (d)false
    Show answer and step marks
    1. Correct option: (d) false. Recall that the default value for a boolean instance or class variable in Java is false.+1
    Answer: (d)
  2. Q2Multiple choice1 mark
    Which of the following is a valid identifier in Java?
    1. (a)total_marks
    2. (b)2ndValue
    3. (c)int
    4. (d)total-marks
    Show answer and step marks
    1. Correct option: (a) total_marks+1
    Answer: (a)
  3. Q3Short answer2 marks
    Distinguish between ASCII and Unicode character sets with respect to the storage size and the total number of characters represented.
    Show answer and step marks
    1. 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
    2. Number of characters: ASCII represents 128128 characters (256256 in extended ASCII), whereas 16-bit Unicode represents 6553665536 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 128128 characters (256256 extended); Unicode in Java uses 16 bits (2 bytes) for 6553665536 characters, extended beyond a million through surrogate pairs.
  4. Q4Short answer2 marks
    Explain 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
    1. 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
    2. 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.
  5. Q5Long answer4 marks
    A 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
    1. (a) Each char value occupies 16 bits (2 bytes), since Java uses 16-bit Unicode for char+1
    2. (b) char omega = '\u03A9';+1
    3. (c) ASCII uses 7 bits, giving only 128 codes that cover English letters, digits and common symbols+1
    4. (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.
  6. Q6Long answer4 marks
    Answer the following questions based on escape sequences in Java: (a) Explain the purpose of the escape sequences `\n\n` and `\t\t` with a suitable `System.out.println()` statement for each. (b) Predict the exact output of the following Java code snippet: System.out.println("Java\tProgramming\tProgramming\n\n" + "\"Class IX\"");
    Show answer and step marks
    1. (a) `\n\n` (new line) moves the cursor to the beginning of the next line.+0.5
    2. (a) Example: System.out.println("Hello\nWorld\nWorld"); prints Hello and World on two separate lines.+0.5
    3. (a) `\t\t` (horizontal tab) moves the cursor to the next tab stop, leaving a gap.+0.5
    4. (a) Example: System.out.println("Roll\tName\tName"); prints Roll, a tab space, then Name on one line.+0.5
    5. (b) First line of output: Java, a tab space, then Programming (Java Programming).+1
    6. (b) Second line of output: "Class IX" (printed with the double quotes).+1
    Answer: (a) `\n\n` moves the cursor to the next line, e.g. System.out.println("Hello\nWorld\nWorld"); prints Hello and World on separate lines. `\t\t` inserts a horizontal tab, e.g. System.out.println("Roll\tName\tName"); 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
See a sample marked answer sheet

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

More Class 9 Computer Applications mock tests