Let us begin with the honest truth about this unit. Almost every ICSE Class 10 student opens the Computer Applications book, sees the words abstraction, encapsulation, inheritance, polymorphism sitting in a row, and quietly decides that this is the boring theory part to be crammed the night before the paper. That decision costs marks every single year, because these four words are not decoration. They are the reason Java is built the way it is, and once you actually understand them, class design questions in Section B stop feeling like guesswork.
So we are going to do this properly. No definitions dropped on you from a height. Every idea here starts from something you already do in ordinary life, and only then do we put the technical word on it. By the end of this page you will be able to explain what an object is without reciting a line, you will know exactly what happens between pressing compile and seeing output, and you will have written and traced real programs that run.
One promise before we start: every program on this page has been compiled and executed on JDK 11 before it was printed here. The output you see below each program is the output the machine actually produced, not what it should have produced. Type them yourself and you will get the same thing.
- Where This Unit Sits in the ICSE Class 10 Syllabus (and the Paper Pattern)
- Procedure-Oriented vs Object-Oriented Programming
- The Four Principles of OOP, Explained With Real Life
- Objects and Classes — State, Behaviour and the Object Factory
- From Source Code to Output — Compiler, Bytecode, JVM
- Features of Java — and How to Write Them in an Answer
- Applications and Applets — the Two Kinds of Java Program
- The Standard Structure of a Java Class
- Four Worked Programs With Verified Output
- Dry Run and Output Prediction — the ICSE Favourite
- Practice Worksheet — 10 Questions With Model Answers
Your Game Plan
Follow these five steps in order and this unit is finished in one focused sitting. Skipping straight to the four principles is the usual mistake.
- Get the object idea first. Read the objects and classes section until you can describe your own school bag as an object with state and behaviour. Everything else rests on this.
- Learn the four principles with your own examples — not the ones printed here. An example you invented is one you cannot forget in the exam hall.
- Type all four programs in BlueJ or any editor on JDK 11 or higher. Reading Java does not teach Java.
- Do the dry run section with a pen. Write the value of every variable after every line. This is exactly how Section A output questions are earned.
- Finish with the worksheet, answers hidden. Write first, reveal second. That gap is where your marks live.
Where This Unit Sits in the ICSE Class 10 Syllabus (and the Paper Pattern)
Open the official CISCE syllabus for Computer Applications (subject code 86) and look at the Class X section. The very first topic is Revision of Class IX Syllabus, and the first item inside it is Introduction to Object Oriented Programming concepts, followed by Elementary Concept of Objects and Classes. That word revision misleads a lot of students into thinking it will not be asked. It is asked, and it is asked in Section A where every mark is compulsory.
Inside the two-hour paper, CISCE’s own published analysis of the Computer Applications paper shows the structure as Section A (40 marks, attempt all questions) and Section B (60 marks, answer any four questions). Section A is where this unit lives: definitions, one-line explanations, output questions. Section B is class design and full programs.
Practical consequence: your laboratory file is worth exactly as much as the written paper. Students who write a brilliant paper and hand in a thin practical file lose half the subject.
How those 100 internal marks are actually split: class design 10, variable description 10, coding and documentation 10, and execution or output 20 — by each of the two examiners. Notice that execution or output is worth double any other criterion. A file full of elegant-looking programs that were never actually run is the single most expensive mistake in this subject.
Syllabus year note: this is the CISCE syllabus for Examination Year 2027. From Year 2028 the internal assessment changes to 15 laboratory assignments plus a 20-mark written project on Disruptive Technologies, and the Class X theory course drops Encapsulation and double dimensional arrays. If you are in Class 9 now, use the 2028 document instead.
Two smaller notes on the syllabus that save arguments later. First, bitwise and shift operators are outside the scope of this course, so do not lose evenings on them. Second, the recommended environment is BlueJ 5.4.2 or higher with JDK 11 or higher, which is exactly what the programs on this page were tested on. Any editor works, but if your school uses BlueJ, use BlueJ — the examiner’s expectations are shaped by it.
Procedure-Oriented vs Object-Oriented Programming
Imagine two ways of running a school canteen. In the first, there is one long instruction sheet pinned to the wall: boil water, then add tea leaves, then collect money, then wash the cup, then call the next student. Everything is one sequence of steps, and the sugar jar sits on an open shelf where anybody passing can dip a spoon into it. That is procedure-oriented programming. The program is a list of procedures acting on data that is largely open to all of them.
In the second canteen, there is a tea counter, a cash counter and a washing station. Each one keeps its own things and does its own job, and if the cash counter needs tea it asks the tea counter rather than reaching over and grabbing it. That is object-oriented programming. The program is a set of objects, each holding its own data and offering a set of operations, and work gets done by objects sending messages to each other.
| Procedure-Oriented Programming | Object-Oriented Programming |
|---|---|
| The program is divided into functions. | The program is divided into objects. |
| Importance is given to the sequence of steps. | Importance is given to the data and to who owns it. |
| Data moves openly between functions; global data is common. | Data is hidden inside objects and reached through methods. |
| Follows a top-down approach. | Follows a bottom-up approach. |
| Adding a new feature often means editing many functions. | A new feature is often a new class, leaving old code untouched. |
| Examples: C, Pascal, FORTRAN. | Examples: Java, C++, Python. |
If a question asks for the difference and carries three marks, give three paired differences like the rows above — one side then the other side of the same point. Writing three facts about POP and then three unrelated facts about OOP is the commonest way students lose a mark here.
The Four Principles of OOP, Explained With Real Life
The syllabus asks for all four to be defined and explained using real life examples. That phrase is a gift: it tells you the examiner wants an example, so always give one.
1. Data abstraction. Showing only what is necessary and hiding the complicated detail behind it. When you switch on a ceiling fan you turn a regulator. You do not think about the capacitor, the winding or the phase difference. The regulator is the abstraction: essential controls exposed, mechanism hidden. In Java, when you call Math.sqrt(25) you get 5.0 without knowing the algorithm inside.
2. Encapsulation. Wrapping data and the methods that operate on that data into a single unit, and controlling access to that data. A medicine capsule holds its powder inside a shell; you cannot take out half the powder without breaking it open. In Java, a class that keeps balance as private and only allows changes through a deposit() method is encapsulated — the data cannot be corrupted from outside.
3. Inheritance. One class acquiring the properties and behaviours of another class, so that common features are written once and reused. A child inherits eye colour from a parent and still has features of their own. In programming, a general class Vehicle can hold speed and start(), and Car and Bus inherit those and add their own. The class inherited from is the base or super class; the one that inherits is the derived or sub class. The real benefit is reusability — say that word in your answer.
4. Polymorphism. The same name behaving differently in different situations. The word literally means many forms. Think of the verb run: you run a race, you run a shop, you run a program — one word, meaning fixed by context. In Java you see it when several methods share one name and are told apart by their parameter lists, which is called method overloading. You will meet the third worked program below doing exactly this.
A memory hook that survives exam pressure: A E I P — Abstraction, Encapsulation, Inheritance, Polymorphism. Say it as ay-ee-eye-pee a few times and the four never come out incomplete.
Objects and Classes — State, Behaviour and the Object Factory
Pick up your school identity card. It has a name, a class, a section, a roll number. Those are things it knows. It can be shown at the gate, scanned in the library, presented in an exam hall. Those are things it does. Now notice something: every student in your school has a card with the same set of fields but different values written in them.
The blank printed design of the card is the class. Your particular card, with your name on it, is an object. This gives you the three ways CISCE describes a class, and a good answer mentions all three:
- A class is a blueprint or specification from which objects are created.
- A class is an object factory — it can produce any number of similar objects.
- A class is a user-defined data type with its own data and its own functionality.
And the object, correspondingly, is an instance of a class that encapsulates state and behaviour. State is stored in member variables (also called attributes or data members). Behaviour is provided by member methods. Work happens when one object calls a method on another — which is why OOP people describe computation as message passing between objects.
Object: an object is an instance of a class that encapsulates state, held in its member variables, and behaviour, provided by its member methods.
These two sentences, written cleanly, are worth two marks each in Section A almost every year. There is no reason to improvise them under pressure.
From Source Code to Output — Compiler, Bytecode, JVM
This is the topic students answer most vaguely, so let us walk the journey of a single file.
You type your program in an editor and save it as FirstProgram.java. What you typed is source code — instructions in a language a human can read. The machine cannot run it.
You now compile it. The Java compiler, javac, checks your syntax and, if it is satisfied, produces a file called FirstProgram.class. The contents of that file are bytecode — a compact, machine-independent set of instructions meant not for your processor but for an imaginary computer called the Java Virtual Machine. This is the single most important idea in the whole section: Java does not compile straight to the instructions of your particular chip.
You then run the program. The JVM for your operating system reads the bytecode and, line by line, converts it into object code — the actual instructions your processor understands — and executes it. Because the bytecode is the same everywhere and only the JVM differs from platform to platform, the identical .class file runs on Windows, on Linux and on a Mac. That is what the slogan write once, run anywhere means, and it is the reason Java is called platform independent.
| Term | What it means |
|---|---|
| Source code | The program as written by the programmer in Java, stored in a .java file. |
| Compiler (javac) | Translates source code into bytecode and reports syntax errors. |
| Bytecode | Machine-independent intermediate code stored in a .class file, understood by the JVM. |
| JVM | The Java Virtual Machine — the interpreter that converts bytecode into object code and runs it. |
| Object code | The machine-level code actually executed by the processor. |
Runtime errors appear while the program is running — dividing by zero, or reading past the end of an array. The program starts and then stops abnormally.
Logical errors break nothing at all. The program compiles, runs, and produces a confidently wrong answer, usually because you wrote a plus where a minus belonged. These are the hardest to find, which is exactly why dry running matters.
Features of Java — and How to Write Them in an Answer
Do not write a bare list. Each feature gets its name and one clause of justification, because the justification is what carries the mark.
- Simple — its syntax is close to C and C++, but confusing features such as pointers and explicit memory freeing have been removed.
- Object oriented — apart from the primitive types, everything in Java is written in terms of classes and objects.
- Platform independent — bytecode runs on any machine that has a JVM, so the same .class file works everywhere.
- Robust — strict type checking, automatic garbage collection and exception handling stop a great many crashes before they happen.
- Secure — programs run inside the JVM, which restricts what they may touch on the host machine.
- Portable — the size of each primitive type is fixed by the language, so an int is 32 bits on every machine.
- Multithreaded — a single program can carry out several tasks at the same time.
- Distributed — it has built-in support for working across networks.
Real applications built with Java, useful if a question asks where Java is used: Android and other mobile applications, desktop applications, web-based systems such as banking and e-commerce portals, games, robotics in healthcare, education software such as online quiz and grading systems, chatbots and virtual assistants.
Applications and Applets — the Two Kinds of Java Program
A Java application is a standalone program. It has a main() method, you run it yourself from the command line or from BlueJ, and it needs nothing but a JVM. Every program on this page is an application.
A Java applet is a small program that cannot run on its own. It has no main(), it is embedded in a web page, and it is executed by a browser or an applet viewer. Applets are legacy technology now and are not used in modern web development, but the syllabus expects you to know the distinction, so learn it as: an application is standalone and starts at main; an applet is embedded and is run by a browser.
The Standard Structure of a Java Class
The syllabus prints a standard skeleton, and it is worth being precise about one thing that confuses almost everybody. The skeleton is written as void main() and the syllabus notes that public, static and String args[] are default in nature. That is a BlueJ convenience: inside BlueJ you may call a method directly on an object, so a plain main() works there.
The moment you run a program from outside BlueJ, the JVM will only start at a method whose full signature is public static void main(String args[]). So write the full signature. It is correct everywhere, including in BlueJ, and no examiner has ever deducted a mark for it. Put it plainly: the short form works only inside BlueJ, while the full form works everywhere including BlueJ. There is no situation in which writing the full signature can cost you anything, and there are several in which the short one can. Write it in full on your answer sheet, every time. Every program below uses it, which is precisely why every one of them actually ran.
// this is a single line comment - non executable
/* this is a
multi line comment - also non executable */
import java.util.*; // needed only when Scanner is used
class NameOfTheClass
{
public static void main(String args[])
{
// declaration of variables
// create an object of the Scanner class if input is needed
// set of statements
}
}
Three rules that cost marks when forgotten. The file name must match the class name exactly, including capitals, so class Student lives in Student.java. Java is case sensitive, so System and system are different words. And every executable statement ends in a semicolon, while a class or method block ends in a closing brace with no semicolon after it.
Four Worked Programs With Verified Output
Each program below was compiled with javac and executed on JDK 11. The output block under each one is copied from the terminal, character for character.
class FirstProgram
{
public static void main(String args[])
{
System.out.print("Principal Saab ");
System.out.print("Computer Applications");
System.out.println();
System.out.println("ICSE Class 10");
System.out.println("Java is fun");
}
}
Output
Principal Saab Computer Applications
ICSE Class 10
Java is fun
What to notice: print() leaves the cursor on the same line, so the first two statements land side by side. println() moves the cursor to the next line after printing, and an empty println() simply ends the current line. This distinction is a favourite one-mark question.class Student
{
// attributes -> the STATE of the object
private String name;
private int marks;
// method to set the state
void setDetails(String n, int m)
{
name = n;
marks = m;
}
// method that uses the state -> the BEHAVIOUR of the object
void display()
{
System.out.println("Name : " + name);
System.out.println("Marks : " + marks);
}
public static void main(String args[])
{
Student s1 = new Student();
Student s2 = new Student();
s1.setDetails("Aarav", 87);
s2.setDetails("Diya", 92);
s1.display();
s2.display();
}
}
Output
Name : Aarav
Marks : 87
Name : Diya
Marks : 92
What to notice: one class produced two objects, and each object kept its own copy of name and marks. That is the object factory idea made visible. Also note new Student() — the new operator allocates memory for the object at run time, and the dot operator in s1.display() is how you reach a member of a particular object.class AreaCalculator
{
// same name, different parameter lists -> method overloading
void area(int side)
{
System.out.println("Area of square = " + (side * side));
}
void area(int length, int breadth)
{
System.out.println("Area of rectangle = " + (length * breadth));
}
void area(double radius)
{
System.out.println("Area of circle = " + (3.14 * radius * radius));
}
public static void main(String args[])
{
AreaCalculator obj = new AreaCalculator();
obj.area(5);
obj.area(4, 6);
obj.area(7.0);
}
}
Output
Area of square = 25
Area of rectangle = 24
Area of circle = 153.86
What to notice: three methods share the name area. The compiler decides which one to run by looking at the number and types of the arguments — not at the return type. Notice also that the third call is written obj.area(7.0) and not obj.area(7). Writing 7 would match the int version and print 49. That is precisely the trap an output question sets.class BankAccount
{
private double balance; // hidden from the outside world
void deposit(double amt)
{
if (amt > 0)
balance = balance + amt;
else
System.out.println("Invalid amount rejected");
}
double getBalance()
{
return balance;
}
public static void main(String args[])
{
BankAccount a = new BankAccount();
a.deposit(5000);
a.deposit(-200);
a.deposit(1500);
System.out.println("Balance = " + a.getBalance());
}
}
Output
Invalid amount rejected
Balance = 6500.0
What to notice: two things students often get wrong. First, the rejection message prints before the balance line even though the bad deposit was the second statement — because the message is printed the moment the bad call happens, while the balance is printed only at the end. Second, the balance shows as 6500.0 and not 6500, because it is a double. Copying the type of the output exactly is worth a mark.Now the real point: because
balance is private, there is no way for outside code to write a.balance = -99999;. Every change must pass through deposit(), which checks the value first. That is encapsulation earning its keep, not just defining itself.Dry Run and Output Prediction — the ICSE Favourite
Section A almost always contains questions that hand you a fragment of code and ask what it prints. There is a method to these, and the method is not cleverness. It is bookkeeping. Take a sheet, write one column for each variable, and after every single statement write the new value. Never hold two changing values in your head at once.
Work through these three before reading the outputs. All three were executed, and the outputs shown are the machine’s.
int a = 5, b = 2;
System.out.println(a / b);
System.out.println(a % b);
System.out.println((double) a / b);
System.out.println(a + b + "Java");
System.out.println("Java" + a + b);
Output
2
1
2.5
7Java
Java52
Reasoning line by line. 5 / 2 is integer division because both operands are int, so the fractional part is thrown away and you get 2, not 2.5. 5 % 2 is the remainder, 1. Casting a to double makes it 5.0 / 2, and one double operand is enough to make the whole expression double, so 2.5.The last two lines are the important ones. Java evaluates left to right. In
a + b + "Java" it first does 5 + 2 as arithmetic and gets 7, then meets a String and switches to concatenation, giving 7Java. In "Java" + a + b it meets the String immediately, so every plus after that is concatenation: Java, then 5, then 2. Same numbers, different order, different answer.class Counter
{
static int count = 0; // shared by ALL objects
int id; // separate for each object
Counter()
{
count++;
id = count;
}
void show()
{
System.out.println("Object id = " + id + " , total objects = " + count);
}
}
class Q2
{
public static void main(String args[])
{
Counter c1 = new Counter();
Counter c2 = new Counter();
Counter c3 = new Counter();
c1.show();
c2.show();
c3.show();
}
}
Output
Object id = 1 , total objects = 3
Object id = 2 , total objects = 3
Object id = 3 , total objects = 3
Reasoning. All three objects are created first, so by the time any show() runs, count has already climbed to 3. But each object captured its own id at the moment it was born, and id is a non-static instance variable, so each object kept a different one. The pattern to remember: a static variable belongs to the class and there is only one copy; an instance variable belongs to the object and there is one copy per object. Half the trap here is not the static keyword at all — it is that the printing happens after all the creating. Good to know rather than compulsory: the syllabus asks you to know static and non-static methods, and you will meet
static again in main() and in the Math class. A static variable like this counter is one step beyond what is usually asked, so treat it as a bonus that sharpens your understanding of what an instance variable really is.int x = 10;
int y = x++;
int z = ++x;
System.out.println(x + " " + y + " " + z);
System.out.println(x++ + ++x);
Output
12 10 12
26
Reasoning, slowly. Start with x = 10. In y = x++ the postfix form uses the old value and then increases, so y receives 10 and x becomes 11. In z = ++x the prefix form increases first and then uses, so x becomes 12 and z receives 12. The first print is therefore 12, 10, 12.Now the second line, with x sitting at 12. Java evaluates left to right.
x++ contributes 12 and leaves x at 13. Then ++x raises x to 14 and contributes 14. So the sum is 12 + 14 = 26. Write the running value of x beside each operand and this stops being frightening.Practice Worksheet — 10 Questions With Model Answers
This is the part that moves marks. Keep paper beside you, write your full answer, and only then click to reveal. Comparing your attempt against the model is worth ten times more than reading the model and nodding.
Q1. (2 marks) Define a class and an object. State the relationship between them.
Q2. (2 marks) Distinguish between abstraction and encapsulation, giving one example of each.
Math.sqrt(25) without knowing the algorithm used.Encapsulation means wrapping data and the methods that act on that data into a single unit and restricting direct access to the data. Example: a class in which
balance is declared private and can only be changed through a deposit() method.In one line: abstraction hides complexity, encapsulation hides data.
Q3. (3 marks) Give three differences between procedure-oriented and object-oriented programming.
2. Procedure-oriented programming gives importance to the sequence of steps, while object-oriented programming gives importance to the data and to the object that owns it.
3. In procedure-oriented programming data moves freely between functions and global data is common, whereas in object-oriented programming data is hidden inside objects and accessed only through their methods.
(Any three correctly paired differences are acceptable. Each difference must state both sides of the same point.)
Q4. (3 marks) Explain the terms source code, bytecode and object code, and name the component that converts bytecode to object code.
Bytecode is the machine-independent intermediate code produced by the Java compiler and stored in a .class file; it is meant for the Java Virtual Machine rather than for any particular processor.
Object code is the machine-level code that the processor of a particular computer can actually execute.
The Java Virtual Machine (JVM) converts bytecode into object code and executes it. Because only the JVM differs from one platform to another while the bytecode stays the same, Java programs are platform independent.
Q5. (2 marks) Predict the output.
System.out.print("ICSE ");
System.out.print("Class 10");
System.out.println();
System.out.println("Computer");
System.out.print("Class 10");
System.out.println();
System.out.println("Computer");
ICSE Class 10
ComputerThe two print() statements place their text on the same line because print() does not move the cursor to a new line. The empty println() then ends that line, and the last statement prints on the next line.Q6. (2 marks) Predict the output.
int p = 8, q = 3;
System.out.println(p / q);
System.out.println(p % q);
System.out.println(p + q + "Total");
System.out.println("Total" + p + q);
System.out.println(p / q);
System.out.println(p % q);
System.out.println(p + q + "Total");
System.out.println("Total" + p + q);
2
2
11Total
Total83Both p and q are int, so 8 / 3 discards the fraction and gives 2, and 8 % 3 gives the remainder 2. In the third line the two integers are added first, giving 11, before concatenation begins. In the fourth line the String comes first, so every plus after it is concatenation.Q7. (2 marks) Predict the output.
int m = 4;
int n = m++;
int r = ++m;
System.out.println(m + " " + n + " " + r);
int n = m++;
int r = ++m;
System.out.println(m + " " + n + " " + r);
6 4 6Start with m = 4. In n = m++ the postfix operator supplies the old value 4 to n and then makes m equal to 5. In r = ++m the prefix operator first raises m to 6 and then supplies 6 to r. So m is 6, n is 4 and r is 6.Q8. (2 marks) Name and explain the two operators used in the statement Student s1 = new Student(); s1.display();
s1. This is called dynamic memory allocation.The dot operator is the member access operator; it is used to invoke a member method or access a member variable of a particular object, here calling
display() on the object referred to by s1.Q9. (3 marks) Name the three kinds of error that can occur in a Java program, and give one example of each.
Runtime error — an error that occurs while the program is executing, causing abnormal termination. Example: attempting to divide an integer by zero.
Logical error — an error in the reasoning of the program; it compiles and runs but produces a wrong result. Example: writing
a - b when the sum a + b was intended.Q10. (4 marks) Define a class Book with member variables title and price, a method to accept values through parameters and a method to display them. Create one object in main() and show the output your program would produce.
class Book
{
private String title;
private double price;
void setData(String t, double p)
{
title = t;
price = p;
}
void display()
{
System.out.println("Title : " + title);
System.out.println("Price : " + price);
}
public static void main(String args[])
{
Book b = new Book();
b.setData("Atlas", 350.0);
b.display();
}
}OutputTitle : Atlas
Price : 350.0Marks are given for: correct class header and braces, both member variables declared private with correct types, a method that accepts values through parameters, a display method using println, and an object created with new in main. Note the price prints as 350.0 and not 350, because it is a double.Before You Close This Page
Look at what you can now do. You can explain why object-oriented programming exists rather than reciting that it does. You can define a class three different ways and an object one precise way. You can trace a program from source code through bytecode to output and name what does the converting. You have written four programs that ran, and you have traced three fragments where the trap was not the syntax but the order of evaluation.
If one of those still feels shaky, go back to that single section. Do not reread the whole page. And if the shaky one is the four principles, do this instead of rereading: pick any object in the room you are sitting in and describe it in all four terms. A mobile phone works beautifully. That five-minute exercise fixes the topic better than an hour of revision.
