ICSE · Class 10 · Computer Applications

Class 10 Library Classes Mock Test (ICSE)

6 practice questions from Library Classes, 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 Library Classes

  • Wrapper classes
  • Autoboxing and unboxing
  • Character class methods
  • Parsing strings to numbers with Integer.parseInt and Double.parseDouble
  • Packages and import

Library Classes practice questions with answers

  1. Q1Multiple choice1 mark
    Which method is used to convert a String representation of a decimal number into a primitive double value?
    1. (a)Double.parseDouble()
    2. (b)Float.parseFloat()
    3. (c)Integer.parseInt()
    4. (d)Double.valueOf()
    Show answer and step marks
    1. Correct option: (a) Double.parseDouble()+1
    Answer: (a)
  2. Q2Multiple choice1 mark
    What is autoboxing in Java?
    1. (a)Automatic conversion of a wrapper class object to its primitive type
    2. (b)Manual conversion using the valueOf() method
    3. (c)Automatic conversion of a primitive type to its corresponding wrapper class object
    4. (d)Converting a String to an integer using parseInt()
    Show answer and step marks
    1. Correct option: (c) Automatic conversion of a primitive type to its corresponding wrapper class object+1
    Answer: (c)
  3. Q3Multiple choice1 mark
    What will be the output of the following statement? `System.out.println(Character.isLetter('9'));`
    1. (a)9
    2. (b)false
    3. (c)true
    4. (d)Compilation error
    Show answer and step marks
    1. Correct option: (b) false+1
    Answer: (b)
  4. Q4Short answer2 marks
    What is a wrapper class in Java? State the primitive data types corresponding to the `Integer` and `Character` wrapper classes.
    Show answer and step marks
    1. A wrapper class is a class that wraps (encapsulates) a value of a primitive data type into an object.+1
    2. `Integer` corresponds to `int`.+0.5
    3. `Character` corresponds to `char`.+0.5
    Answer: A wrapper class wraps a primitive type into an object; Integer corresponds to int and Character corresponds to char.
  5. Q5Long answer4 marks
    Write a Java program to accept an integer number using the Scanner class. Store this value in a primitive int variable, perform autoboxing to store it in an Integer wrapper object, unbox it to perform arithmetic addition of 55, and finally print the updated value using System.out.println.
    Show answer and step marks
    1. `import java.util.Scanner;` with the class and `main` method declared correctly.+1
    2. `Scanner` object created and the integer read into a primitive `int` variable with `nextInt()`.+1
    3. Autoboxing: assigning the primitive to a wrapper object, `Integer boxed = n;`.+0.5
    4. Unboxing: using the wrapper object in arithmetic, `int updated = boxed + 5;`.+0.5
    5. Printing the updated value with `System.out.println` and a message.+1
    Answer: import java.util.Scanner; class BoxingDemo { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.print("Enter an integer: "); int n = sc.nextInt(); Integer boxed = n; int updated = boxed + 5; System.out.println("Updated value = " + updated); } } Here Integer boxed = n; is autoboxing and boxed + 5 unboxes boxed to an int.
  6. Q6Long answer4 marks
    Write a Java program using the `Scanner` class to accept 1010 integer numbers from the user and store them in an `Integer` array, thereby demonstrating **autoboxing**. Then, traverse the array to compute the sum of all the numbers and find the maximum number, thereby demonstrating **unboxing**. Finally, display the calculated sum and the maximum number.
    Show answer and step marks
    1. `import java.util.Scanner;`, the class and `main` declared, and a `Scanner` object created.+0.5
    2. `Integer arr[] = new Integer[10];` filled in a loop with `arr[i] = sc.nextInt();`, the `int` values being autoboxed.+1
    3. Sum: `sum = sum + arr[i];` in a loop, each `Integer` unboxed to `int`.+0.5
    4. Maximum: `max` initialised to `arr[0]` and replaced whenever `arr[i] > max`.+1
    5. Display of the sum.+0.5
    6. Display of the maximum.+0.5
    Answer: import java.util.Scanner; class WrapperArray { public static void main(String args[]) { Scanner sc = new Scanner(System.in); Integer arr[] = new Integer[10]; System.out.println("Enter 10 integers:"); for (int i = 0; i < 10; i++) { arr[i] = sc.nextInt(); } int sum = 0; int max = arr[0]; for (int i = 0; i < 10; i++) { sum = sum + arr[i]; if (arr[i] > max) max = arr[i]; } System.out.println("Sum = " + sum); System.out.println("Maximum = " + max); } }

Take a full Library Classes 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 Library Classes 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 10 Computer Applications mock tests