Values and Data Types ICSE Class 10 Computer Applications
Updated 14 October 2026 · Fact-checked
Java has eight primitive data types (byte, short, int, long, float, double, char, boolean) with fixed sizes, plus non-primitive types such as classes, arrays and String. Programs are built from tokens: keywords, identifiers, literals, punctuators and operators. Values convert implicitly (widening) or by explicit type casting, and chars follow ASCII/Unicode codes.
What Values and Data Types is about
Every Java value has a type that decides how much memory it uses and what can be done with it. Small slips here cost marks across the paper: typecasting a char (2024), 'Z' + 32 (2025), bytes used by arrays (2024, 2025), escape sequences (2024, 2025), and parseDouble with casting (2024).
The syllabus asks for: character set, ASCII code, Unicode, escape sequences (\n, \t, \\, \", \'), tokens and their types (keywords, identifiers, literals, punctuators, operators), constants and variables, primitive and non-primitive data types with sizes in bits and bytes, and implicit and explicit type conversion.
Weightage: CISCE publishes no chapter weightage. Section A (40 marks) is compulsory: 1-mark MCQs and 2-mark short answers including output and error questions; in Section B you answer any four of six 15-mark programming questions written in Java.Source: CISCE ICSE Computer Applications (661) specimen paper structure for 2027
Key concepts
- Character set, ASCII and Unicode
The character set of Java is the set of characters it recognises: letters (A-Z, a-z), digits (0-9), special symbols and white space. Java uses Unicode, a 16-bit code that can represent characters of almost all world languages (65,536 codes in its basic form). The first 128 Unicode codes are the same as ASCII (American Standard Code for Information Interchange), a 7-bit code.
Useful ASCII codes: 'A' to 'Z' = 65 to 90; 'a' to 'z' = 97 to 122; '0' to '9' = 48 to 57; space = 32. The gap between an upper-case letter and its lower-case form is 32 ('a' − 'A' = 32).
A char used in arithmetic is promoted to its integer code: 'A' + 1 = 66.
Worked example
(1 mark) What is printed by System.out.println('Z' + 32); ?
(a) z
(b) Z
(c) 122
(d) 154Try it first, then show the solutionSolution
- 'Z' is 90; char + int gives int 122, printed as a number.
Answer: (c) 122
- Escape sequences
An escape sequence is a backslash (\) followed by a character, used inside a string or char literal to represent a special character. The syllabus lists:
\n - new line
\t - horizontal tab
\\ - backslash
\" - double quote
\' - single quoteExample: System.out.println("She said, \"Hi!\"\nBye"); prints
She said, "Hi!"
ByeNote the backslash (\), not the forward slash (/): "/n" prints the two characters / and n.
Worked example
(2 marks) Give the output: System.out.println("Tab\there\\ok\'s");
Try it first, then show the solutionSolution
- \t gives a tab between Tab and here - 1 mark.
- \\ prints one backslash; \' prints a single quote - 1 mark.
Answer: Tab here\ok's (a tab space after Tab)
- Tokens: keywords, identifiers, literals, punctuators, operators
A token is the smallest individual unit of a program.
(1) Keywords: reserved words with special meaning that cannot be used as names: class, int, double, if, else, for, while, new, return, void, static, public, private, final, break.
(2) Identifiers: names given by the programmer to variables, methods, classes and arrays. Rules: may contain letters, digits, underscore (_) and dollar sign; must not start with a digit; no spaces; cannot be a keyword; case sensitive. Valid: total, _rate, mark2; invalid: 2mark, my total, class.
(3) Literals (constants): fixed values written in the program: integer (25), floating-point (3.14, 2.5f), character ('A'), string ("Java"), boolean (true, false), and null.
(4) Punctuators (separators): ; , . ( ) { } [ ]
(5) Operators: symbols that perform operations: + - * / % = == && etc.Worked example
(2 marks) Classify as keyword, identifier or literal: (a) while (b) totalMarks (c) 'x' (d) 45.6
Try it first, then show the solutionSolution
- (a) keyword; (b) identifier - 1 mark.
- (c) character literal; (d) floating-point literal - 1 mark.
Answer: (a) keyword, (b) identifier, (c) character literal, (d) floating-point (real) literal.
- Variables, constants and primitive data types
A variable is a named memory location whose value can change: int age = 15;. A constant is a variable whose value cannot change once assigned, declared with final: final double PI = 3.14159;.
Primitive (built-in) data types and sizes:
byte - 1 byte (8 bits), whole numbers −128 to 127
short - 2 bytes (16 bits)
int - 4 bytes (32 bits), default for whole numbers
long - 8 bytes (64 bits), literal with L, e.g. 9000000000L
float - 4 bytes (32 bits), literal with f, e.g. 2.5f
double - 8 bytes (64 bits), default for decimals
char - 2 bytes (16 bits), one Unicode character in single quotes
boolean - true or false only (holds one bit of information; Java does not fix its storage size)Non-primitive (reference, composite) types: class, array, interface and String. They are built from primitives, are user-defined or library-defined, and hold references to objects.
Memory used by an array = number of elements × size of each: char c[4][3] uses 12 × 2 = 24 bytes; double x[] = {2.5, 4.5, 5.5, 6.4} uses 4 × 8 = 32 bytes.
Worked example
(1 mark) How many bytes does a character array of 4 rows and 3 columns occupy?
(a) 12
(b) 24
(c) 48
(d) 96Try it first, then show the solutionSolution
- 4 × 3 = 12 elements; each char is 2 bytes; 12 × 2 = 24.
Answer: (b) 24
- Type conversion: implicit and explicit
Implicit (automatic, widening) conversion: Java converts a smaller type to a larger one by itself when they are mixed in an expression or assigned, with no loss of data. Order: byte → short → int → long → float → double; char → int. Examples: double d = 5; gives 5.0; 'A' + 2 gives 67 (int); 7 / 2.0 gives 3.5 because 7 is widened to double.
Explicit conversion (type casting, narrowing): the programmer forces a conversion by writing the type in brackets; it may lose data. Examples: (int) 7.9 gives 7 (decimal part dropped, not rounded); (char) 98 gives 'b'; (int) 'a' gives 97; (double) 7 / 2 gives 3.5.
Integer division: when both operands are int, the result is int: 7 / 2 = 3, and double d = 7 / 2; gives 3.0 (division happens before widening).
String joining: + with a String concatenates: "A" + 'B' gives "AB"; 1 + 2 + "3" gives "33" (left to right: 1 + 2 = 3, then "3" + "3"); "1" + 2 + 3 gives "123".
Worked example
(2 marks) String s1 = "45.50"; String s2 = "54.50"; double d1 = Double.parseDouble(s1); double d2 = Double.parseDouble(s2); int x = (int)(d1 + d2); What is x?
Try it first, then show the solutionSolution
- parseDouble converts the strings: d1 = 45.5, d2 = 54.5; sum = 100.0 - 1 mark.
- (int) 100.0 = 100 - 1 mark.
Answer: x = 100
Values and Data Types in real life
Each concept, met in an everyday situation. Read the situation, answer the question in your own words, then compare with the model answer. The one-line hook is what to remember.
Choosing data types
Suppose you are writing a program for a school canteen that stores: number of samosas sold today, price of a sandwich in rupees and paise, whether a student has a meal pass, and the grade letter on a coupon.
Choose a suitable data type for each.
Try it first, then show the solutionSolution
- Count of samosas: whole number: int.
- Price with paise: decimal: double.
- Meal pass yes/no: boolean.
- Grade letter: char.
Answer: int samosas; double price; boolean hasPass; char grade;
Memory hook: Count with int, money with double, yes/no with boolean, one letter with char.
Type casting loses data
Imagine a shopkeeper's program calculates a bill of ₹249.90 and stores it with int bill = (int) 249.90; before printing.
What will be printed, and what has gone wrong?
Try it first, then show the solutionSolution
- Casting a double to int drops the decimal part.
- (int) 249.90 = 249, not 250 (no rounding).
- The 90 paise is lost; money should stay double.
Answer: 249 is printed; explicit narrowing cast truncated the decimal part, so 90 paise was lost.
Memory hook: Casting cuts, it never rounds.
Unicode
Suppose your friend types her name in Hindi in a Java program and it displays correctly.
Why can Java handle Hindi characters while ASCII cannot?
Try it first, then show the solutionSolution
- ASCII has only 128 codes, mostly English characters.
- Java's char uses 16-bit Unicode, which covers characters of most world scripts.
- So Hindi letters have their own codes.
Answer: Because Java stores characters in 16-bit Unicode, which includes Hindi and other scripts, while ASCII covers only 128 English-centred characters.
Memory hook: ASCII is English; Unicode is the world.
Topics in this chapter
Values and Data Types: syntax and key facts
- Sizes (bytes)
- byte 1, short 2, int 4, long 8, float 4, double 8, char 2, boolean true/false
- Bits = bytes × 8.
- ASCII anchors
- 'A' = 65, 'a' = 97, '0' = 48, space = 32; lower − upper = 32
- char + int → int.
- Widening order
- 1.byte
- 2.short
- 3.int
- 4.long
- 5.float
- 6.double; char
- 7.int
- Implicit; narrowing needs a cast.
- Array memory
- bytes = number of elements × size of element type
- double[4] = 32 bytes; char[4][3] = 24 bytes.
- Escape sequences
- \n new line, \t tab, \\ backslash, \" double quote, \' single quote
- Backslash, not slash.
How the board asks Values and Data Types
The question patterns to expect, and the method that works for each.
| Question type | How it is asked | Method |
|---|---|---|
| MCQ (Section A) | (char)98 (2024); 'Z' + 32 (2025); escape sequence identification (2024) and output (2025); bytes in arrays (2024, 2025); user-defined types (2025). | Remember ASCII anchors, type sizes and the backslash; apply widening rules step by step. |
| Short answer (2 marks) | parseDouble and cast (2024); boxing vs unboxing (2024); give output of mixed expressions. | Evaluate left to right, noting where int division, widening or string joining happens. |
| Program (15 marks) | Programs use these ideas: choosing types, casting chars to codes and back, converting case. | Declare each variable with a suitable type and cast explicitly when going from a larger type to a smaller one. |
Tricks to remember Values and Data Types
Short memory aids. Say each one aloud once, then use it on a question the same day.
B-S-I-L-F-D = 1-2-4-8-4-8
byte 1, short 2, int 4, long 8, float 4, double 8; char 2.
Use it when: Sizes in bytes.
65-97-48
A is 65, a is 97, zero is 48.
Use it when: ASCII questions.
Back for escape
Escape needs the backslash, which leans back: \n.
Use it when: Escape sequences.
Values and Data Types: board-level solved questions
Ordered from board level to HOTS. Cover the solution, write your own, then compare step by step.
Example 1: Typecasting a char · 1 mark · MCQBoard level
int x = 98; char ch = (char) x; What is stored in ch?
(a) b
(b) A
(c) B
(d) 97
Try it first, then show the solutionSolution
- 97 is 'a', so 98 is 'b'.
Answer: (a) b
Example 2: User-defined types · 1 mark · MCQHarder board level
Which of these are user-defined (non-primitive) data types?
1. array 2. double 3. class 4. boolean
(a) only 1
(b) 1 and 3
(c) only 2
(d) only 4
Try it first, then show the solutionSolution
- double and boolean are primitive; array and class are non-primitive.
Answer: (b) 1 and 3
Example 3: Escape sequence output · 1 mark · MCQHarder board level
Give the output of: System.out.println("I said, \"It\'s fine.\"");
(a) I said, It's fine.
(b) I said, "It's fine."
(c) I said, \"It's fine.\"
(d) error
Try it first, then show the solutionSolution
- \" prints " and \' prints '.
Answer: (b) I said, "It's fine."
Example 4: Mixed expressions · 2 marks · Short answerHOTS / competency
Give the output of each:
(a) System.out.println('A' + 'B');
(b) System.out.println("A" + 'B');
(c) System.out.println(1 + 2 + "3");
(d) System.out.println("1" + 2 + 3);
Try it first, then show the solutionSolution
- (a) char + char = int: 65 + 66 = 131.
- (b) String + char joins: AB.
- (c) 1 + 2 = 3 first, then "3" + "3" = 33.
- (d) "1" + 2 = "12", then + 3 = "123".
Answer: (a) 131 (b) AB (c) 33 (d) 123
Example 5: Integer division and casting · 2 marks · Short answerHarder board level
int a = 7, b = 2; Give the values of: (i) a / b (ii) (double) a / b (iii) (double)(a / b) (iv) a % b
Try it first, then show the solutionSolution
- (i) int / int = 3. (ii) 7.0 / 2 = 3.5.
- (iii) a / b = 3 first, then 3.0. (iv) remainder 1.
Answer: (i) 3 (ii) 3.5 (iii) 3.0 (iv) 1
Example 6: Character information program · 15 marks · Long answerHarder board level
Write a program to accept a letter and print (i) its ASCII code, (ii) the next character, and (iii) the letter in the opposite case, using type conversion (no library methods for case).
Try it first, then show the solutionSolution
- import java.util.Scanner;
class CharInfo
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter a letter: ");
char ch = sc.next().charAt(0); - int code = ch;
System.out.println("ASCII code = " + code);
char nxt = (char)(ch + 1);
System.out.println("Next character = " + nxt); - if (ch >= 'a' && ch <= 'z')
System.out.println("Upper case = " + (char)(ch - 32));
else if (ch >= 'A' && ch <= 'Z')
System.out.println("Lower case = " + (char)(ch + 32));
}
} - int code = ch; is implicit widening (char to int); (char)(ch + 1) is explicit casting because ch + 1 is an int.
- Trace with input g: code = 103; next = (char)104 = h; g is lower case, so (char)(103 − 32) = (char)71 = G.
Answer: Sample run:
Enter a letter: g
ASCII code = 103
Next character = h
Upper case = G
Example 7: Spot the invalid declarations · 2 marks · Short answerHOTS / competency
Two of these declarations do not compile. Identify them and correct each.
(i) float rate = 4.5;
(ii) long pop = 9000000000L;
(iii) boolean ok = 1;
(iv) double avg = 7;
Try it first, then show the solutionSolution
- (i) 4.5 is a double literal and cannot be stored in a float without f: float rate = 4.5f; (iii) boolean takes only true or false: boolean ok = true; - 1 mark each.
- (ii) is valid (long literal with L) and (iv) is valid (the int 7 is widened to 7.0).
Answer: Invalid: (i) and (iii). Corrections: float rate = 4.5f; and boolean ok = true;. (ii) and (iv) compile.
Case-study practice (Section B style)
Read the situation, then answer every part. In the board paper this is a 10-mark question split into 2 + 3 + 5 marks.
A student database
Imagine Kabir is writing a program to store each student's roll number (up to 4 digits), height in metres (like 1.62), house letter ('R', 'G', 'B' or 'Y'), whether fees are paid, and the total population of the city (about 12,000,000). He also stores the marks of 40 students in an array of double.
(i) · 2 marks
Choose types for roll number, height and house letter.
Answer
Answer: int (or short) roll number; double height; char house.
Roll and height 1 mark; house 1 mark.
(ii) · 3 marks
Choose types for fees paid and city population, and give their sizes in bits.
Answer
Answer: boolean feesPaid (true/false; it holds one bit of information, though Java does not fix its storage size); int population (32 bits) is enough for 12,000,000, or long (64 bits) for safety.
Types 2 marks; size 1 mark.
(iii) · 5 marks
How many bytes does the marks array use? If he writes int avg = total / 40; where total is double, what error occurs and how is it fixed?
Answer
Answer: 40 × 8 = 320 bytes. total / 40 is double, and assigning a double to int is a narrowing conversion, so it is a compile-time error ('possible lossy conversion'). Fix: double avg = total / 40; or int avg = (int)(total / 40); (the cast drops decimals).
Bytes 2 marks; error 1 mark; fix 2 marks.
Where the marks are
How a typical answer is split into step marks. Show every step: a right final answer alone rarely earns full marks.
Give the output of 'Z' + 32 and (char)('Z' + 32). (2 marks) (2 marks)
| Step | Marks |
|---|---|
| 'Z' + 32 = 90 + 32 = 122 (int). | 1 |
| (char)122 = z. | 1 |
Program: accept a letter; print ASCII code, next character and opposite case. (15 marks) (15 marks)
| Step | Marks |
|---|---|
| Class, main and Scanner set-up. | 2 |
| Accepting a char with next().charAt(0). | 2 |
| ASCII code by implicit conversion. | 2 |
| Next character with explicit cast. | 3 |
| Case test with correct ranges. | 3 |
| Opposite case by ±32 with cast; output labels. | 3 |
Where students lose marks in Values and Data Types
The slips examiners see most often, and what to write instead.
Mistake: Unsure of typecasting and ASCII values
The 2024 examiners noted candidates lacked clarity on (char)98 and were unsure when options were letters.
Do this: Memorise 65, 97 and 48 and count from them.
Usually costs: 1 mark.
Mistake: Writing z or 154 for 'Z' + 32
The 2025 examiners reported confusion over implicit casting of char in arithmetic.
Do this: char + int gives an int; println prints the number 122.
Usually costs: 1 mark.
Mistake: Forward slash in escape sequences
In 2024 candidates confused / with \; in 2025 punctuation and escape sequences confused them.
Do this: Escape sequences always use the backslash.
Usually costs: 1 mark.
Mistake: Rounding before adding, or concatenating strings
In the 2024 parseDouble question candidates rounded first, ignored the cast or joined the strings.
Do this: Convert with parseDouble, add as doubles, then cast the sum.
Usually costs: 1 to 2 marks.
Mistake: Wrong bytes for arrays
In 2024 some wrote 48 for a 4 × 3 char array; in 2025 some miscounted a double array.
Do this: Elements × size of type (char 2, double 8).
Usually costs: 1 mark.
Practice questions on Values and Data Types
Write each answer on paper first. Open the hint only if you are stuck, and the answer only when you have finished.
Q1 · 1 mark · MCQBoard level
Which of these is an escape sequence?
(a) /n
(b) \t
(c) /t
(d) //nHint
Backslash.
Answer
(b) \t
Q2 · 1 mark · MCQBoard level
The size of a char in Java is:
(a) 1 byte
(b) 2 bytes
(c) 4 bytes
(d) 8 bytesHint
Unicode.
Answer
(b) 2 bytes
Q3 · 1 mark · MCQBoard level
double x[] = {2.5, 4.5, 5.5, 6.4}; occupies:
(a) 16 bytes
(b) 4 bytes
(c) 8 bytes
(d) 32 bytesHint
4 × 8.
Answer
(d) 32 bytes
Q4 · 2 marks · Very short answerBoard level
Distinguish between implicit and explicit type conversion with one example each.
Hint
Automatic vs cast.
Answer
Implicit conversion is done automatically by Java from a smaller to a larger type, e.g. double d = 10; stores 10.0. Explicit conversion (type casting) is forced by the programmer, possibly losing data, e.g. int n = (int) 9.8; stores 9.
Q5 · 2 marks · Very short answerHarder board level
State whether valid or invalid identifiers: (a) _sum (b) total marks (c) Class (d) 3rd
Hint
Case-sensitive keyword check.
Answer
(a) valid (b) invalid: contains a space (c) valid: Class differs from the keyword class (d) invalid: starts with a digit.
Q6 · 2 marks · Very short answerHarder board level
Give the output: char c = 'D'; int n = c + 3; System.out.println(n); System.out.println((char) n);
Hint
D is 68.
Answer
71
GQ7 · 2 marks · Short answerHOTS / competency
Give the output: System.out.println(10 / 4 * 4 + " " + 10 / 4.0 * 4);
Hint
Integer division first.
Answer
8 10.0 (10 / 4 = 2, × 4 = 8; 10 / 4.0 = 2.5, × 4 = 10.0)
Q8 · 15 marks · Long answerHOTS / competency
Write a program to accept a digit character (for example '7') and print the integer value it represents and that value doubled, using type conversion only.
Hint
Subtract '0' (48).
Answer
import java.util.Scanner;
class DigitValue
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter a digit: ");
char ch = sc.next().charAt(0);
int value = ch - '0';
System.out.println("Value = " + value);
System.out.println("Double = " + (value * 2));
}
}
Trace with '7': '7' is 55, 55 − 48 = 7; Value = 7, Double = 14.Q9 · 2 marks · Short answerHOTS / competency
Why does double d = 7 / 2; store 3.0 and not 3.5?
Hint
Order of events.
Answer
Both 7 and 2 are int, so 7 / 2 is integer division giving 3; only then is 3 widened to 3.0 for the double variable.
Test your recall
Answer in your head or on paper first, then open the card. Pulling an answer out of memory makes it stick far better than re-reading.
1.ASCII code of 'a'?Show answer
97
2.Size of double in bits?Show answer
64
3.Is String primitive?Show answer
No; it is a class (non-primitive).
4.(int) 9.99 = ?Show answer
9
5.Name the five types of tokens.Show answer
Keywords, identifiers, literals, punctuators, operators.
Best order to study it
- Character set, ASCII anchors, Unicode.
- Escape sequences.
- Tokens and identifier rules.
- Primitive types with sizes; non-primitive types.
- Implicit and explicit conversion; integer division; string joining.
- Practise output questions daily.
Quick revision checklist
The night before the exam: can you do each of these without looking?
- Unicode 16-bit; ASCII 7-bit; A 65, a 97, 0 48.
- \n \t \\ \" \' with backslash.
- Tokens: keywords, identifiers, literals, punctuators, operators.
- byte 1, short 2, int 4, long 8, float 4, double 8, char 2 bytes; boolean true/false.
- Widening is automatic; narrowing needs (type) and truncates.
- int / int gives int; + with a String joins.
Values and Data Types: frequently asked questions
What is the default type of a decimal literal like 4.5?
double. To store it in a float, write 4.5f.
Is null a literal?
Yes, null is a literal meaning 'no object', used with reference types such as String.
Does casting round a decimal?
No. (int) 7.9 is 7; use Math.round() to round.
Based on: CISCE ICSE 2027 Computer Applications syllabus; CISCE Analysis of Pupil Performance ICSE 2025: Computer Applications (with the 2025 board paper)