ICSE Class 10 · Computer Applications (Java) · Values, data types and input 2027

Data types in Java for ICSE Class 10, with casting and Scanner input.

Data types in Java for ICSE Class 10 decide what a variable can hold, how much memory it takes and what an expression gives back. Questions on them run through the whole paper: name the type of a literal, state the result type of a mixed expression, cast a value, or read input with Scanner. This page has the primitive table with ranges, sixteen conversions worked to their result, the Scanner method table and the one input bug that catches nearly every student. Everything was run in Java 21, and our live mini batch drills it in BlueJ.

Live online · 8 primitive types · 16 casts worked · Scanner methods · the nextLine pitfall fixed · first class free

Start here

Courses that teach types and input properly

Three routes: our ICSE Computer Applications batch, which drills types, casts and Scanner input every week; ISC-level Computer Science for the years after the board; and data structures for a student who wonders how values sit in memory.

Ans. The short version

Java has eight primitive data types: byte, short, int and long for whole numbers, float and double for decimals, char for one character and boolean for true or false. String, arrays and objects are non-primitive types. In a mixed expression Java widens the smaller type itself (implicit conversion, or coercion); moving to a smaller type needs an explicit cast, so (int) 9.99 gives 9. ICSE input uses the Scanner class, where nextLine straight after nextInt returns an empty String. Our ICSE mini batch practises all of it on Tuesday and Wednesday evenings in India, with one to one classes for any other time.

Q1. What are the data types in Java?

Values and data types ICSE: the eight primitive types

A data type tells Java what kind of value a variable holds, how much memory it uses and which operations are allowed. The ranges and default values below were printed by Java itself from each type's MIN_VALUE and MAX_VALUE constants and from unassigned fields.

TypeHoldsSizeRangeDefaultLiteral
byteSmall whole number8 bits-128 to 1270None; byte b = 12; works
shortWhole number16 bits-32768 to 327670None; short s = 900; works
intWhole number32 bits-2147483648 to 21474836470425
longLarge whole number64 bitsAbout ±9.22 x 101803000000000L
floatDecimal, about 7 digits32 bitsUp to about 3.4 x 10380.02.75f
doubleDecimal, about 15 digits64 bitsUp to about 1.8 x 103080.02.75
charOne Unicode character16 bitsCodes 0 to 65535Code 0'k'
booleantrue or falseNot fixed in bits by Javatrue, falsefalsetrue

Default values apply to instance variables and array elements only. A local variable inside a method has no default, which is why using one before giving it a value does not compile. String, arrays and class objects are non-primitive (reference) types: their default is null.

Literals and escape sequences

LiteralTypeEscape sequenceMeaning
64, -3int (integer literal)\nNew line
64Llong\tHorizontal tab
6.4, 6.4e2double (real literal)\\One backslash
6.4ffloat\"Double quote inside a String
'6'char (character literal)\'Single quote
"6"String (string literal)Run: System.out.println("A\tB\\C\"D\'E"); printed A, a tab, then B\C"D'E
true, falseboolean literals (the word null is the null literal)An escape sequence counts as one character: '\n' is a single char

Q2. What is implicit and explicit type casting in Java?

Implicit and explicit type casting ICSE, worked to the result

Implicit conversion (coercion, or widening) is done by Java on its own when a smaller type meets a larger one. Explicit conversion (type casting, or narrowing) is written by the programmer as (type) value and may lose data. The widening order is byte, short, int, long, float, double, with char widening to int.

#CodeResult (run)Kind and reason
1int a = 7; double x = 2.5;
a + x
9.5Implicit: int widened to double
2char ch = 'A';
ch + 3
68Implicit: char widened to int, code 65 plus 3
3short s1 = 10, s2 = 20;
int sum = s1 + s2;
30Implicit: short arithmetic is done in int
4byte p = 10, q = 20;
byte r = p + q;
Does not compilejavac: possible lossy conversion from int to byte; write (byte) (p + q)
510 / 4 * 4.08.010 / 4 is int 2 first; only then widened for * 4.0
65 / 2.0f2.5Implicit: int widened to float
7float ff = 1.1f;
double dd = ff;
1.100000023841858Implicit widening keeps float's slightly inexact value
8(int) 9.99 and (int) -9.999 and -9Explicit: the fraction is cut off, never rounded
9(int) 7.5 and Math.round(7.5)7 and 8A cast truncates; round rounds
10(char) 66 and (int) 'z'B and 122Explicit: between a code and its character
11(byte) 200-56Explicit narrowing out of range wraps round: 200 minus 256
12double avg = (double) (17 + 18) / 2;17.5Explicit: the cast makes 35 a double before the division
13char cc = 'A' + 2;CAllowed: a constant that fits in char needs no cast
14'a' + 'b' and "" + 'a' + 'b'195 and abTwo chars add as ints (97 + 98); a String first makes them join
15int big = 2147483647;
big = big + 1;
-2147483648Overflow: past the int maximum the value wraps to the minimum, with no error
1686400 * 1000 * 365 and 86400L * 1000 * 3651471228928 and 31536000000Milliseconds in a year overflow int; one L makes the whole product long

Writing long n = 3000000000; without the L does not even compile: javac says integer number too large, because a plain whole-number literal is an int. The return type of each Math method, which decides many of these results, is on Math library methods for ICSE Class 10, and how the operators combine types is on operators in Java for ICSE Class 10.

Q3. How do you take input in Java using the Scanner class?

Scanner class input ICSE: every method and what it reads

Import java.util.Scanner (or java.util.*), create one object with new Scanner(System.in), print a prompt, then call the method that matches the type you want. Each next method skips leading spaces and reads one token; nextLine reads everything up to the end of the line.

MethodReturnsReadsIf the input does not fit
nextInt()intOne whole-number tokenInputMismatchException
nextLong(), nextShort(), nextByte()long, short, byteOne whole-number token in that type's rangeInputMismatchException
nextDouble(), nextFloat()double, floatOne number token; 12 is read as 12.0InputMismatchException
nextBoolean()booleanThe token true or false, in any caseInputMismatchException
next()StringOne word: stops at a spaceAlways works on text
nextLine()StringThe rest of the current line, spaces includedReturns "" if only the line end is left
next().charAt(0)charThe first character of the next wordThere is no nextChar() method
Six methods, one inputnext against nextLine
Scanner sc = new Scanner(System.in);
String first = sc.next();
String rest = sc.nextLine();
char grade = sc.next().charAt(0);
double fee = sc.nextDouble();
boolean paid = sc.nextBoolean();
long phone = sc.nextLong();

// Input line 1: Ananya Rao Kumar
// Input line 2: B+ 1250.75 true 9876543210
// first = [Ananya]  rest = [ Rao Kumar]
// grade = [B]  fee = [1250.75]
// paid = [true]  phone = [9876543210]

next stopped at the first space; nextLine took the rest, including its leading space. charAt(0) kept only B from the token B+. A ten-digit phone number needs nextLong, since it is beyond the int range.

To readUse
Marks, age, countnextInt()
Price, percentage, radiusnextDouble()
Phone or account numbernextLong()
One word, such as a citynext()
A full name or sentencenextLine()
A grade or menu letternext().charAt(0)

Values can also reach a program through initialisation in the code or as method parameters, which BlueJ asks for in a dialog box when the method is called. Converting a String that was read into a number uses the parse methods covered on wrapper and library classes for ICSE Class 10.

Q4. Why does nextLine() skip input after nextInt()?

The nextLine pitfall: why the text comes back empty, and the fix

nextInt reads the digits but leaves the Enter key, the line end, waiting in the input. The nextLine that follows finds that line end straight away and returns an empty String, so the program never waits for the text. Add one extra nextLine() call after nextInt to use up the leftover line end.

Faultythe name is skipped
import java.util.Scanner;

public class Pitfall2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Flat number: ");
        int flat = in.nextInt();
        System.out.print("Society: ");
        String society = in.nextLine();
        System.out.println(flat + ", " + society + ".");
    }
}
// Typed: 402, Enter, Green Meadows, Enter
// Printed: 402, .

The program printed the second prompt and finished at once: society is the empty String left over from the first line.

Fixedone extra line
import java.util.Scanner;

public class Fixed2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.print("Flat number: ");
        int flat = in.nextInt();
        in.nextLine();
        System.out.print("Society: ");
        String society = in.nextLine();
        System.out.println(flat + ", " + society + ".");
    }
}
// Typed: 402, Enter, Green Meadows, Enter
// Printed: 402, Green Meadows.

The lone in.nextLine() reads and throws away the line end after 402, so the next call waits for the society name.

A Section B input program that avoids the pitfall

Name first, numbers aftermarks, percentage and band
import java.util.Scanner;

public class Report {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Name: ");
        String name = sc.nextLine();
        System.out.print("Marks in 5 subjects: ");
        int total = 0;
        for (int k = 1; k <= 5; k++)
            total += sc.nextInt();
        double percent = total / 5.0;
        int rounded = (int) Math.round(percent);
        char band = percent >= 90 ? 'A' : percent >= 75 ? 'B' : 'C';
        System.out.println(name + ": total " + total + ", "
            + percent + "%, rounded " + rounded + ", band " + band);
    }
}
// Input: Ishaan Mehta / 88 92 79 95 82
// Ishaan Mehta: total 436, 87.2%, rounded 87, band B

Reading the full name before any number sidesteps the pitfall entirely. Two casts appear: 5.0 makes the percentage a double, and (int) turns the long from Math.round into an int.

VariableTypePurpose
nameStringFull name, read with nextLine
totalintSum of the five marks
kintLoop counter, 1 to 5
percentdoubleAverage, with decimals kept
roundedintPercentage to the nearest whole number
bandcharA, B or C from the percentage

A wrong token typed into nextInt stops the program with InputMismatchException; that and other crashes are classified on ICSE Java error finding questions.

Q5. How are data types asked in Section A?

Type conversion Java ICSE: the question shapes and how to answer

Section A is 40 compulsory marks of one-mark MCQs and two-mark parts, and this chapter supplies a steady share of both. The shapes repeat, so a fixed answer habit for each one is worth building.

"Name the data type of"

Look at the literal itself: a decimal point means double unless it ends in f; single quotes mean char; double quotes mean String, even for one letter or a digit.

"State the result type"

Find the largest type in the expression after char, byte and short have become int. That type is the answer, and the value must be written in it: 8.0, not 8.

"Implicit or explicit?"

If you can see a (type) in brackets, it is explicit. If Java converts on its own because a smaller type met a bigger one, it is implicit, also called coercion or widening.

"Primitive or non-primitive?"

The eight keywords in the table are primitive. String, arrays and classes are non-primitive, also called reference or composite types.

"Write the statement to input"

Match the method to the type: a ten-digit number needs nextLong, a character needs next().charAt(0). Declare the variable in the same line.

"Size in bytes"

Convert the bits: byte 1, short 2, int 4, long 8, float 4, double 8, char 2. Writing bits when bytes are asked is a common lost mark.

Mixed one-mark questions from every chapter are on ICSE Computer Applications MCQ questions, and the Class 9 chapters that this page revises are mapped on Class 9 Java revision for Class 10.

Q6. How are data types and input taught live?

How the mini batch practises types, casts and input

Types are learnt by predicting a result type before running the code, and input is learnt by typing real values into real programs. The week is split that way.

  1. Tuesday: predict the type, then the value

    At 5:30 PM IST the batch gets a timed set of mixed expressions and casts. Each answer is written as a type and a value, such as "double, 8.0".

  2. BlueJ checks each one live

    Every expression is run on a shared screen. A missing .0 or a wrongly rounded cast is spotted by the whole group, not just the student who wrote it.

  3. Wednesday: input programs

    At 8:00 PM IST students write a Section B program that reads mixed input with Scanner. The nextLine pitfall is triggered on purpose once, so nobody meets it for the first time in an exam.

  4. Variable lists every time

    Each program ends with a variable list of name, type and purpose, the habit the ICSE paper asks for in its instructions.

  5. Full papers from December

    Timed two-hour mock papers then mix type and input questions into both sections, and each script is marked the way an ICSE examiner would mark it.

Data types and input are the base for every program on ICSE Class 10 Java programs for practice.

Batch or personalised: you choose

Practise types and input in the mini batch, or one to one

What changes between the two formats is only the timing and the group. The type drills and input programs are identical. Families abroad are taught privately; families in India may choose. You pay month by month and there is no joining fee.

Option 1 · Fixed batch timings

Mini batch, Tuesday 5:30 PM and Wednesday 8 PM

₹2,999

per month, two live classes a week

  • Two fixed evenings: Tuesday 5:30 PM and Wednesday 8:00 PM IST
  • Never more than six students in the group
  • Timed result-type and casting sets each Tuesday
  • A Scanner input program written each Wednesday
  • Every cast and input run in BlueJ on screen
Book a free demo in this batch

Option 2 · Choose your own timing

Personalised one to one

₹4,999

per month, one private class a week, at a time set with you

  • Days and hours you choose, wherever you live
  • Extra time on the conversions your child gets wrong
  • Their own input programs debugged with them
  • Class 9 gaps in this chapter filled first
  • The teachers and 2027 syllabus of the batch, at your pace
Ask for a personalised plan

A student who joined ICSE Computer Applications late, or whose Class 9 basics are shaky, often needs a few one to one sessions on types and input before the rest of Class 10 makes sense. A student who is already comfortable and wants steady weekly practice across the paper is better served by the batch. Fees are shown in your own currency.

Studying outside India?

Data types and input practice for ICSE students abroad

An ICSE school in the UAE or Singapore follows the same Computer Applications syllabus and paper, so the same type and input questions decide the same marks. Outside India the drills run one to one, after school in the student's own time zone.

Where you liveTime differenceUsual class window, local timeFormat
India (IST)
every Indian city
ISTTue 5:30 PM, Wed 8:00 PMMini batch or 1-on-1
United Arab Emirates
Dubai, Sharjah
1 h 30 min behind India3:00 PM to 9:00 PMPersonalised 1-on-1
Indonesia and Thailand
West Java, Bangkok area
1 h 30 min ahead of India3:30 PM to 9:00 PMPersonalised 1-on-1
Singapore
Singapore
2 h 30 min ahead of India3:30 PM to 9:00 PMPersonalised 1-on-1

The slot is agreed after the free demo and can move around school tests. How overseas classes run is described on ICSE Computer Applications classes in the Gulf and abroad.

What families say

Rated 4.9 across 547 Google reviews

Real reviews from real families. We neither write nor commission them.

★★★★★

"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."

Ria Mukherjee

Parent

★★★★★

"Modern Age Coders has been a game-changer for me. I struggled to grasp IT concepts and coding before joining, but their classes transformed everything. I can now confidently write complex programs with ease."

Samriddha Mondal

Student

★★★★★

"One of the most wonderful education centres out there. Education is not limited to school syllabus but focuses on skill development."

Vansh Agarwal

Student

★★★★★

"My child Dhairya is really enjoying the Modern Age Coders classes. This is his first online class and he eagerly looks forward to it. I can already see his improvement, and the teachers are very cooperative."

Sonam Oswal

Parent of Dhairya

★★★★★

"Modern Age Coders have wonderful teachers who teach in a clear, easy and practical way. The teacher boosts students' confidence and inspires them to learn without hesitation."

Sonu Goyal

Parent

★★★★★

"I highly recommend this computer coding class! The teachers are incredibly knowledgeable and passionate about coding."

Ritu Kedia

Parent

The rest of the Class 10 series

More pages for Class 10 board students

Every page in the ICSE Class 10 Computer Applications series, grouped by what you need: classes, each chapter, Section B programs, question practice, notes and revision, and the exam itself.

CBSE Class 10 AI (417): The Mon and Wed 9 PM AI batch CBSE AI 417 syllabus explained CBSE AI important questions Sample paper and mock tests

Questions about data types and input

What students ask about data types and Scanner input in ICSE Java

How many data types are there in Java?

Java has eight primitive data types: byte, short, int, long, float, double, char and boolean. Besides these there are non-primitive, or reference, types such as String, arrays and classes, which hold a reference to an object rather than the value itself. ICSE expects the eight primitive types with their sizes.

What is the difference between primitive and non-primitive data types?

Primitive types are built into Java, store the value directly and have a fixed size, such as int at 32 bits. Non-primitive types, such as String, arrays and class types, are created from classes, store a reference to an object, can be null, and can have methods called on them.

What is implicit type conversion in Java?

Implicit conversion, also called coercion or widening, is the automatic change of a smaller type into a larger one when they meet in an expression or assignment. For example, an int added to a double is converted to double first, so 7 + 2.5 gives 9.5. No data is lost, so Java does it without being asked.

What is explicit type casting in Java with an example?

Explicit casting is a conversion the programmer writes by putting the target type in brackets before a value. (int) 9.99 gives 9, because the fraction is cut off, and (char) 66 gives B. It is needed whenever a value moves to a smaller type, such as double to int, since data may be lost.

What is the size of char in Java?

char is 16 bits, which is 2 bytes, because Java stores characters in Unicode. It holds codes from 0 to 65535. This differs from languages that use 1 byte for a character, and ICSE questions sometimes test exactly that difference.

Which Scanner method is used to input a character in Java?

Scanner has no nextChar method. The usual way is sc.next().charAt(0), which reads the next word as a String and keeps its first character. If the user types more than one character, only the first is kept, so B+ would give B.

What is the difference between next() and nextLine()?

next() reads one word: it skips leading spaces and stops at the next space or line end. nextLine() reads the whole rest of the current line, spaces included, and then moves past the line end. Use next() for one word such as a city and nextLine() for a full name or a sentence.

Why is nextLine() skipped after nextInt()?

nextInt() reads the number but leaves the line end from the Enter key in the input. The next nextLine() reads up to that line end at once and returns an empty String, so it looks as if the input was skipped. Call sc.nextLine() once more after nextInt() to use up the leftover line end.

What is the default value of a variable in Java?

Instance variables and array elements get defaults: 0 for whole-number types, 0.0 for float and double, the character with code 0 for char, false for boolean and null for String and other references. Local variables inside a method get no default and must be assigned before use, or the program will not compile.

Do you teach data types and Scanner input in the live ICSE classes?

Yes. The mini batch drills result types and casts in timed sets every Tuesday at 5:30 PM IST and writes a Scanner input program every Wednesday at 8:00 PM IST, with every answer run in BlueJ on a shared screen. Students who need gaps filled from Class 9 can take personalised one to one classes.

Start

Book a free live class on data types and input

In the free demo your child predicts the type and value of a few mixed expressions and casts, writes a short Scanner program with the mentor, and watches both run in BlueJ, including the nextLine pitfall and its fix. Afterwards you hear plainly which basics need work and whether the mini batch or one to one suits your child better.

Want more first? See operators in Java for ICSE Class 10 or the ICSE Class 10 Java classes.

WhatsApp us · +91 91233 66161 · connect@modernagecoders.com

Every class is live video. The form requests a callback and reserves nothing.

We call within a few hours. No card, no enrolment fee.

Want it sooner? Book a priority demo

A full live class of about 45 to 60 minutes at a slot you pick, with a written skill report and learning roadmap on WhatsApp afterwards. The fee is adjusted against your first month if you enrol.

Book a priority demo

Keep exploring Modern Age Coders

By class and age

Learn more

Free resources

From the blog

Start here