★★★★★
"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
ICSE Class 10 · Computer Applications (Java) · Encapsulation 2027
Encapsulation in ICSE Class 10 comes down to two questions: which classes can reach a member, and how long a variable lives. The first is answered by the access specifiers, the second by the scope of variables. This page gives the one-line definitions, an access table we checked with the Java compiler across two packages, data hiding with getters and setters, the four kinds of variable, and a Section B class built on private data. In our live mini batch these rules are traced, compiled and written by hand every week.
Live online · access table checked with javac · four kinds of variable · one Section B class with private data · first class free
Start here
The ICSE Java course where the mini batch writes classes with private data every week, the Class 11 and 12 Computer Science course where encapsulation grows into inheritance, and the data structures course for students who want to see why real libraries hide their fields.

The batch / ICSE CA
Class 9 and 10 Computer Applications in a mini batch, where every Section B class is written with private members and public methods.
Open the course →
Next step / ISC
For students going on to ISC, where protected members and inheritance are taught in full.
Open the course →
Beyond the syllabus / DSA
For the student who wants to build a stack or a queue whose insides nobody else can break.
Open the course →Ans. The short version
Encapsulation in ICSE Class 10 means wrapping a class's data and the methods that use it into one unit, and controlling access to that data. Java does it with access specifiers: private (same class only), default with no keyword (same package), protected (same package and subclasses) and public (everywhere). Making data private and reaching it only through public methods is called data hiding. The same 2027 syllabus unit covers the scope of variables: class, instance, argument and local. Modern Age Coders teaches this chapter live in a Tuesday and Wednesday mini batch in India, or one to one at the family's time.
Q1. What are access specifiers in Java?
An access specifier is a keyword placed before a member that decides which other classes may use it. The ICSE syllabus names three, private, protected and public; a member written with no keyword gets a fourth level, called default or package access.
| Specifier | Same class | Another class, same package | Subclass, other package | Any other class, other package |
|---|---|---|---|---|
private | Yes | No | No | No |
| none (default) | Yes | Yes | No | No |
protected | Yes | Yes | Yes | No |
public | Yes | Yes | Yes | Yes |
Read the table as a ladder: each row opens one more door than the row above it. We did not copy it from a book. We wrote a class Locker in a package school with one member at each level, then tried to read all four from three places. Here is what javac 21 reported.
package school;
public class Locker {
private int code = 4821;
int row = 3; // no keyword: default
protected String owner = "Tara";
public int number = 17;
}
Each member is then printed from Office (package school), SportsLocker (package other, extends Locker) and Visitor (package other, unrelated).
school/Office.java:5: error: code has private access in Locker other/SportsLocker.java:5: error: code has private access in Locker other/SportsLocker.java:6: error: row is not public in Locker; cannot be accessed from outside package other/Visitor.java:6: error: code has private access in Locker other/Visitor.java:7: error: row is not public in Locker; cannot be accessed from outside package other/Visitor.java:8: error: owner has protected access in Locker
Every line that is not listed compiled. public number was readable from all three places; private code from none of them.
Binding data and the methods that work on it into a single unit, the class, so that the data is used only in the ways the class allows.
Keeping data members private so that no code outside the class can read or change them directly.
A keyword that sets the visibility of a class member: private, protected, public, or none for default access.
Inheritance is not part of the ICSE Class 10 syllabus, so for the 2027 paper it is enough to know that protected opens a member to subclasses as well as to its own package. Where a class sits among objects and classes generally is covered on class as the basis of all computation.
Q2. How does a class hide its data?
A class hides its data by declaring the members private and offering public methods to read them (accessors, or getters) and to change them (mutators, or setters). The mutator can check a value before accepting it, which is the whole point.
class Thermostat {
private double temp = 24.0;
public double getTemp() { // accessor
return temp;
}
public void setTemp(double t) { // mutator
if (t >= 16 && t <= 30)
temp = t;
else
System.out.println("Rejected: " + t);
}
}
class Room {
public static void main(String[] args) {
Thermostat ac = new Thermostat();
ac.setTemp(45);
ac.setTemp(19.5);
System.out.println(ac.getTemp());
}
}
// Output:
Rejected: 45.0
19.5
45 is an int argument, widened to the double 45.0, which is why the message prints 45.0.
class Hack {
public static void main(String[] args) {
Thermostat ac = new Thermostat();
ac.temp = 45; // line 4
System.out.println(ac.getTemp());
}
}
// javac says:
Hack.java:4: error: temp has private access in Thermostat
ac.temp = 45;
^
The program never runs. Because temp is private, the only way to change it is setTemp, and setTemp refuses 45. That refusal is data hiding doing its job.
| Term | What it means | In the Thermostat class |
|---|---|---|
| Encapsulation | Data and methods bundled in one class | temp, getTemp and setTemp live together in Thermostat |
| Data hiding | Data kept out of reach of other classes | temp is private, so Room cannot touch it |
| Abstraction | Showing what an object does, not how | Room calls setTemp without knowing the 16 to 30 rule inside it |
double getTemp().void and takes one parameter of the member's type.main if main belongs to that class.The last rule surprises students in output questions: a main written inside the same class can read a private member directly. Constructors that fill private members are on ICSE Class 10 constructors questions.
Q3. What is the scope of a variable?
The scope of a variable is the part of the program in which it can be used, and its lifetime is how long it keeps its value. The syllabus names four kinds, and each is decided purely by where the variable is declared.
| Kind | Declared | Usable in | Lives | Default value? |
|---|---|---|---|---|
| Class variable | In the class, with static | The whole class; outside it as ClassName.var if access allows | As long as the program runs; one copy | Yes (0, 0.0, false, null) |
| Instance variable | In the class, without static | All non-static methods; through an object elsewhere | As long as its object; one copy per object | Yes |
| Argument variable | In a method or constructor header | That method body only | One call of the method | No, it receives the passed value |
| Local variable | Inside a method or a block { } | From its declaration to the end of that block | Until the block ends | No, must be assigned before use |
class Ticket {
static int sold = 0; // class variable
int seat; // instance variable
Ticket(int s) { // s: argument variable
seat = s;
sold++;
}
int price(int rows) { // rows: argument variable
int base = 150; // local variable
return base + rows * 20;
}
public static void main(String[] args) {
Ticket a = new Ticket(12);
Ticket b = new Ticket(30);
System.out.println(a.seat + " " + b.seat + " " + Ticket.sold);
System.out.println(a.price(3));
}
}
// Output:
12 30 2
210
Two objects, so two seats but one sold counter. base and rows vanish when price returns.
class Shadow {
int marks = 40;
void update(int marks) {
marks = marks + 5;
System.out.println(marks + " " + this.marks);
}
void fix(int marks) {
this.marks = marks;
}
public static void main(String[] args) {
Shadow s = new Shadow();
s.update(70);
s.fix(62);
System.out.println(s.marks);
}
}
// Output:
75 40
62
Inside update, plain marks means the parameter, so the member stays 40. this.marks always means the member, which is how fix reaches it.
All five use one class Q with static int count = 10;, int n = 1;, static void bump(int count) { count += 5; } and void twice() { int n = 7; n *= 2; this.n += n; }.
| # | Code in main | Output | The scope rule |
|---|---|---|---|
| 1 | bump(count);System.out.println(count); | 10 | The parameter count is a separate local copy; the class variable is untouched |
| 2 | Q x = new Q();x.twice();System.out.println(x.n); | 15 | The local n becomes 14; this.n is the member, 1 + 14 |
| 3 | Q p = new Q(), r = new Q();p.count++; r.count++;System.out.println(Q.count + " " + p.n); | 12 1 | Both objects share the one static count; each has its own n |
| 4 | int total = 0;for (int i = 1; i <= 4; i++) { int sq = i * i; total += sq; }System.out.println(total); | 30 | sq is created afresh each pass; total lives outside the loop and keeps adding |
| 5 | int k = 3;{ int m = k * 2; k = m + 1; }System.out.println(k); | 7 | m dies at the closing brace, but the change it made to k survives |
int sum = 0;
for (int i = 1; i <= 5; i++)
sum += i;
System.out.println(sum + " " + i); // line 6
// javac says:
Loop.java:6: error: cannot find symbol
symbol: variable i
i was declared in the for header, so it ends with the loop. Declare it before the loop if it is needed afterwards.
void show(int x) {
int x = 5; // line 3
System.out.println(x);
}
// javac says:
Dup.java:3: error: variable x is already defined in method show(int)
A local variable may hide a data member, but it may not reuse the name of a parameter or another local in the same method.
More traces of this kind, mixed with every other trap, sit among the ICSE Java output questions.
Q4. How does encapsulation look in a Section B answer?
Section B questions rarely say "encapsulation", but a full-marks class answer uses it: private data members, a constructor, public methods that check values before changing them, and a variable description table. Here is an original question in board shape.
Question. Define a class MetroCard with private data members holder (String), cardNo (long) and balance (double). Write a parameterised constructor that stores the name and card number and sets the balance to 0. Write public methods: String getHolder() and double getBalance(); void recharge(double amt) which refuses amounts below 100 and adds a bonus of 5% when the amount is 1000 or more; boolean travel(int stations) which charges a fare of 10 for the first station and 4 for every further station, with a ceiling of 60, deducting it only if the balance is enough; and void display(). In main, read the name, card number, a recharge amount and the stations for two trips, and display the card.
import java.util.Scanner;
class MetroCard {
private String holder; // name on the card
private long cardNo; // card number
private double balance; // money left on the card
public MetroCard(String h, long c) {
holder = h;
cardNo = c;
balance = 0.0;
}
public String getHolder() {
return holder;
}
public double getBalance() {
return balance;
}
public void recharge(double amt) {
if (amt < 100) {
System.out.println("Minimum recharge is 100");
return;
}
double bonus = (amt >= 1000) ? amt * 0.05 : 0;
balance = balance + amt + bonus;
}
public boolean travel(int stations) {
int fare = 10 + 4 * (stations - 1);
if (fare > 60)
fare = 60;
if (fare > balance) {
System.out.println("Low balance, fare " + fare);
return false;
}
balance = balance - fare;
return true;
}
public void display() {
System.out.println("Card " + cardNo + " (" + holder + ")");
System.out.println("Balance: " + balance);
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.print("Name and card number: ");
String n = sc.next();
long c = sc.nextLong();
MetroCard card = new MetroCard(n, c);
System.out.print("Recharge amount: ");
card.recharge(sc.nextDouble());
System.out.print("Stations on each of two trips: ");
int t1 = sc.nextInt();
int t2 = sc.nextInt();
card.travel(t1);
card.travel(t2);
card.display();
}
}
No method lets the balance be set to any value directly. Money comes in only through recharge and goes out only through travel, and both check first.
| Variable | Type | Scope | Purpose |
|---|---|---|---|
| holder | String | instance, private | card holder's name |
| cardNo | long | instance, private | card number |
| balance | double | instance, private | money on the card |
| h, c | String, long | argument | values passed to the constructor |
| amt | double | argument | amount offered for recharge |
| bonus | double | local | 5% extra on large recharges |
| stations | int | argument | stations travelled on a trip |
| fare | int | local | fare for one trip, at most 60 |
| sc, n, c, t1, t2, card | various | local to main | input reader, inputs and the object |
Name and card number: Kabir 40071 Recharge amount: 1000 Stations on each of two trips: 6 18 Card 40071 (Kabir) Balance: 960.0 Name and card number: Mira 40072 Recharge amount: 50 Minimum recharge is 100 Stations on each of two trips: 2 3 Low balance, fare 14 Low balance, fare 18 Card 40072 (Mira) Balance: 0.0
Run 1: 1000 plus a bonus of 50 is 1050. Six stations cost 10 + 4 × 5 = 30; eighteen would cost 78, so the ceiling of 60 applies. 1050 − 30 − 60 = 960.
Adding a Scope column to the variable description table, as above, is not required, but it shows the examiner you know the chapter. More classes written to a specification are on ICSE slab and bill programs and user-defined methods and overloading.
Q5. What does Section A ask on this chapter?
In Section A, the 40 compulsory marks, this chapter turns up as one-mark MCQs and two-mark definitions or differences. Try each one before opening the answer.
this, as in this.marks = marks;static.Short difference questions from every chapter, in the same two-mark shape, are collected on ICSE Computer Applications difference between questions.
Q6. How is this chapter taught in the mini batch?
Students remember the access table best after they have watched the compiler refuse a line they were sure would work. So the week is built around predictions that javac then confirms or rejects.
At the Tuesday 5:30 PM IST class the teacher shows a two-package project on a shared screen. Each student marks which lines will compile before BlueJ is asked, and the wrong guesses are discussed first.
Fragments with shadowed names, static counters and block-local variables are traced on paper, one column per variable, until the four kinds of variable feel different rather than merely sound different.
On Wednesday at 8:00 PM IST the group writes a Section B class with private members and checking methods, then marks it against the board scheme on screen, including the variable description table.
The one-line definitions of encapsulation, data hiding and each specifier are rehearsed until each student can say them without notes, which also prepares for the internal assessment viva.
From December, full two-hour mock papers bring the chapter back inside Section A and inside Section B classes, under the real clock.
The wider chapter-by-chapter plan is on ICSE Computer Applications notes, and the oral side is on ICSE Computer Applications viva questions.
Batch or personalised: you choose
The access experiments, the scope traces and the Section B class are the same in either format. Families in India choose between the fixed evening group of six and a private slot; ICSE students abroad are taught one to one. Billing is monthly and there is no admission fee.
Option 1 · Fixed batch timings
₹2,999
per month, two live classes a week
Option 2 · Choose your own timing
₹4,999
per month, one private class a weektwo private classes a week, at a time set with you
Outside India: the ICSE Computer Applications course runs as personalised one to one, two private classes a week at a time set in your own time zone. The mini batch is taught for families in India.
A student who already writes working classes but loses marks on definitions or scope traces usually needs only a handful of one to one sessions on this chapter. A student who is still unsure how a class should be laid out gains more from the steady weekly rhythm of the batch. Fees appear in your own currency.
Studying outside India?
The 2027 Computer Applications paper is the same in Dubai or Singapore as it is in Kolkata, and so is this chapter. Outside India we teach it one to one, at an early evening hour in the student's own time zone.
| Where you live | Time difference | Usual class window, local time | Format |
|---|---|---|---|
| India (IST) every Indian city | IST | Tue 5:30 PM, Wed 8:00 PM | Mini batch or 1-on-1 |
| United Arab Emirates Dubai, Sharjah | 1 h 30 min behind India | 3:00 PM to 9:00 PM | Personalised 1-on-1 |
| Indonesia and Thailand West Java, Bangkok area | 1 h 30 min ahead of India | 3:30 PM to 9:00 PM | Personalised 1-on-1 |
| Singapore Singapore | 2 h 30 min ahead of India | 3:30 PM to 9:00 PM | Personalised 1-on-1 |
The time is fixed after the free demo and can move around school tests. How classes run for overseas families is set out on ICSE Computer Applications classes in the Gulf and abroad.
What families say
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
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 encapsulation
Encapsulation is the wrapping of data and the methods that act on that data into a single unit called a class. In practice it means keeping the data members private and letting other classes use them only through the class's public methods, so the class decides what changes are allowed. It is Unit 6 of the 2026-27 ICSE Computer Applications syllabus.
The syllabus names private, protected and public. private allows access from the same class only; protected from the same package and from subclasses; public from everywhere. A member with no specifier has default, or package, access: any class in the same package can use it, but nothing outside the package can.
They differ in how far a member can be seen. private stops at the class itself. protected reaches the whole package and any subclass, even one in another package. public reaches every class in every package. Data members are usually private and methods that other classes call are public.
Data hiding means keeping a class's data members private so that code outside the class cannot read or change them directly. Other classes must go through public methods, which can check every value first. For example, a private balance changed only by a method that refuses negative amounts can never become negative.
Encapsulation is the bundling of data and methods into one class. Data hiding is one result of it: restricting direct access to that data with the private specifier. A class could bundle data and methods yet leave everything public; that is encapsulated but not hidden, and it is weak design.
Scope is the region of a program where a variable can be used. Class variables (static) and instance variables can be used throughout the class. An argument variable can be used only inside its own method. A local variable can be used only from its declaration to the end of the block in which it is declared.
Class variables, declared static with one shared copy; instance variables, declared in the class without static, one copy per object; argument variables, declared in a method header to receive values; and local variables, declared inside a method or block. The syllabus groups all four under the scope of variables in the Encapsulation unit.
Not directly. The compiler rejects the line with a message such as "temp has private access in Thermostat". The only way in is through a non-private method of the same class, such as a getter that returns the value or a setter that checks and stores a new one.
The syllabus lists protected among the access specifiers, so a one-mark question on its visibility is fair. You need the rule, not inheritance programs: protected allows access within the same package and from subclasses in other packages. Writing subclasses is an ISC topic.
Yes. The ICSE mini batch meets on Tuesday at 5:30 PM IST and Wednesday at 8:00 PM IST with six students at most. Students predict which lines compile, trace scope fragments and write a class with private data each week. Personalised one to one classes are available at a time the family chooses, in India or abroad.
Start
In the free demo your child predicts which lines of a small two-package program will compile, sees BlueJ confirm or reject each guess, and then rewrites one class so its data is private. You then hear honestly which parts of the chapter are secure and whether the mini batch or one to one fits better.
Prefer to look around first? Read ICSE Computer Applications important questions or see 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.
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