★★★★★
"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
ISC Class 11 · Computer Science 868 · Practical
Class 11 is where Java stops being about printing and starts being about planning. These ISC Class 11 Computer Science practical questions come in three sets of three, as in the exam, followed by lab work on files and packages. Each has its algorithm, variables, program and the output it really gave.
Live online · 12 problems run on Java 21 · assignments and project explained · your days and your timing · first class free
Start here
One course for the two years of the subject, one for Java by itself, and one to keep for college.

Two years / 868
The ISC students in this course begin with Java and number systems in Class 11 and go on to data structures and Boolean algebra in Class 12.
Open the course →
Java from zero / Teens
A good bridge for a student who did not take Computer Applications in Class 10 and meets Java for the first time now.
Open the course →
Later / 18+
Written for college students. Bookmark it: the recursion and sorting of Class 11 are its first chapters.
Open the course →Ans. The short version
ISC Class 11 Computer Science practical questions are Java programming problems: the paper gives three, you attempt one, with up to 90 minutes of planning and 90 minutes at the computer. In the ISC 2027 document the Class XI practical carries 30 marks, 15 for that problem, 10 for at least twenty assignments and 5 for one project, and the school evaluates it. This page solves twelve original problems with algorithm, variable table, program and output, from number bases to files and packages. Modern Age Coders teaches Class 11 Java in personalised one to one classes; a priority demo shows you how before you enrol.
Q1. What is the practical in Class 11?
Fifteen for the exam problem, ten for assignments, five for a project. All thirty are awarded inside the school: the Visiting Examiner of Class 12 has no part in Class 11.
Which year these facts are for: they come from the Class XI pages of CISCE’s ISC 2027 document, marked February 2025. If you are in Class 11 in 2026-27, your ISC examination is in 2028, so check the 2028 document with your school.
| Component | Marks | In the document’s terms |
|---|---|---|
| Terminal evaluation | 15 | Solution to a programming problem on the computer, one of three |
| Assignments through the year | 10 | A work file, minimum twenty assignments |
| Project work | 5 | One project based on any topic of the syllabus |
| Practical | 30 | Three hours, with theory at 70 marks in its own three hours |
The exam problem is judged on the choice of algorithm and how it is carried out, on documentation, and on correct output for inputs printed in the question and for others kept by the examiner. The Class XI pages do not divide the 15 further. The table in the same document that splits it as 3, 7, 2 and 3 is filled in by a Visiting Examiner, so it describes Class 12; we use it on the Class 12 practical page.
Class 11 tests are held by schools, on dates each school sets. Where the problems come from is easiest to see section by section.
| Theory section, Class 11 | What it holds | What it lends to the practical |
|---|---|---|
| A. Basic hardware and software | Number bases, binary encodings of integers and reals, characters, propositional logic, gates and adders | Base arithmetic and two’s complement programs |
| B. Object oriented programming in Java | Objects, exceptions, wrapper classes, statements, methods and constructors, arrays, strings | Most exam problems |
| C. Further Java and ethics | Scanner and StringTokenizer, text and binary files, recursion, packages, trends and ethical issues | Recursion problems and several assignments |
Q2. What kind of problem is set?
Three problems that use loops, characters and a two dimensional array, nothing more. Pick one, spend an hour and a half with a pen, and come back. On the output boxes, anything after a prompt was typed by us, and an empty line starts a new run.
Accept a base from 2 to 16 and two whole numbers written in that base, using A to F for ten to fifteen. Add them without converting to decimal, carrying as you would on paper, and print the sum in the same base. A digit that does not belong to the base must be refused.
Algorithm in plain steps
import java.util.Scanner;
/* Set 1, Problem 1: add two numbers written in the same base */
public class BaseAdder {
static final String DIGITS = "0123456789ABCDEF";
// every character must be a digit of the base
static boolean isLegal(String s, int base) {
for (int i = 0; i < s.length(); i++) {
int d = DIGITS.indexOf(s.charAt(i));
if (d < 0 || d >= base)
return false;
}
return s.length() > 0;
}
static String add(String p, String q, int base) {
String answer = "";
int i = p.length() - 1, j = q.length() - 1, carry = 0;
while (i >= 0 || j >= 0 || carry > 0) {
int total = carry;
if (i >= 0)
total += DIGITS.indexOf(p.charAt(i--));
if (j >= 0)
total += DIGITS.indexOf(q.charAt(j--));
answer = DIGITS.charAt(total % base) + answer;
carry = total / base;
}
return answer;
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Base (2 to 16) : ");
int base = scan.nextInt();
System.out.print("First number : ");
String p = scan.next().toUpperCase();
System.out.print("Second number : ");
String q = scan.next().toUpperCase();
if (base < 2 || base > 16
|| !isLegal(p, base) || !isLegal(q, base))
System.out.println("Not a number in that base");
else
System.out.println("Sum : "
+ add(p, q, base));
}
}
Base (2 to 16) : 2 First number : 101101 Second number : 11011 Sum : 1001000 Base (2 to 16) : 16 First number : 2AF Second number : 9d3 Sum : C82 Base (2 to 16) : 8 First number : 178 Second number : 5 Not a number in that base
| Variable | Type | Job |
|---|---|---|
base | int | the base of all three numbers |
p, q | String | the two numbers |
i, j | int | digits being added |
carry | int | carried to the next place |
answer | String | sum built from the right |
Worth noticing: F + 3 in base 16 is eighteen, which is written 2 with 1 carried, just as 9 + 9 is 8 with 1 carried in base 10. The last part of the loop condition, carry > 0, is what prints the extra digit in front.
A hall is stored as a matrix of 0 for a free seat and 1 for a taken one. Find the longest block of free seats side by side in one row, and print the row and the seat numbers counted from 1. If blocks are equal, the first one wins. If no seat is free, print House full.
Algorithm in plain steps
import java.util.Scanner;
/* Set 1, Problem 2: longest run of free seats in a hall */
public class SeatBlock {
private int[][] hall; // 0 free, 1 taken
private int bestRow, bestFrom, bestLen;
boolean accept(Scanner scan) {
System.out.print("Rows and seats: ");
int rows = scan.nextInt(), seats = scan.nextInt();
hall = new int[rows][seats];
for (int r = 0; r < rows; r++) {
System.out.print("Row " + (r + 1) + ": ");
for (int s = 0; s < seats; s++) {
hall[r][s] = scan.nextInt();
if (hall[r][s] != 0 && hall[r][s] != 1)
return false;
}
}
return true;
}
void findBlock() {
for (int r = 0; r < hall.length; r++) {
int len = 0; // free seats in a row so far
for (int s = 0; s < hall[r].length; s++) {
if (hall[r][s] == 1) {
len = 0; // the run is broken
continue;
}
len++;
if (len > bestLen) {
bestLen = len;
bestRow = r + 1;
bestFrom = s - len + 2;
}
}
}
}
public static void main(String[] args) {
SeatBlock h = new SeatBlock();
if (!h.accept(new Scanner(System.in))) {
System.out.println("Use 0 and 1 only");
return;
}
h.findBlock();
if (h.bestLen == 0)
System.out.println("House full");
else
System.out.println("Row " + h.bestRow + ", seats "
+ h.bestFrom + " to "
+ (h.bestFrom + h.bestLen - 1));
}
}
Rows and seats: 3 8 Row 1: 0 1 0 0 0 1 0 0 Row 2: 1 0 0 0 0 1 1 0 Row 3: 0 0 1 0 0 0 0 1 Row 2, seats 2 to 5 Rows and seats: 1 4 Row 1: 1 1 1 1 House full Rows and seats: 1 3 Row 1: 0 2 1 Use 0 and 1 only
| Variable | Type | Job |
|---|---|---|
hall | int[][] | the seats |
len | int | length of the present run |
bestLen | int | longest run found |
bestRow, bestFrom | int | where that run begins |
Worth noticing: rows 2 and 3 both have four seats together, and > keeps row 2. Resetting len at the start of each row matters: without it a run would continue from the end of one row into the next.
On a phone keypad ABC is 2, DEF 3, GHI 4, JKL 5, MNO 6, PQRS 7, TUV 8 and WXYZ 9. Accept a sentence, write each different keypad code once with all the words that share it, and count the codes shared by more than one word.
Algorithm in plain steps
import java.util.Scanner;
/* Set 1, Problem 3: words that share one keypad code */
public class KeypadCode {
// digit under each letter from A to Z on a phone keypad
static final String KEY = "22233344455566677778889999";
static String codeOf(String word) {
String code = "";
for (int i = 0; i < word.length(); i++)
code += KEY.charAt(word.charAt(i) - 'A');
return code;
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Sentence: ");
String s = scan.nextLine().toUpperCase();
// everything that is not a letter becomes a space
String clean = "";
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
clean += (ch >= 'A' && ch <= 'Z') ? ch : ' ';
}
clean = clean.trim();
if (clean.length() == 0) {
System.out.println("No words");
return;
}
String[] word = clean.split(" +");
boolean[] shown = new boolean[word.length];
int shared = 0;
for (int i = 0; i < word.length; i++) {
if (shown[i])
continue;
String code = codeOf(word[i]), group = word[i];
int size = 1;
for (int j = i + 1; j < word.length; j++)
if (codeOf(word[j]).equals(code)) {
group += " " + word[j];
shown[j] = true;
size++;
}
System.out.println(code + " " + group);
if (size > 1)
shared++;
}
System.out.println("Shared codes: " + shared);
}
}
Sentence: Good home, act now: the cat is gone. 4663 GOOD HOME GONE 228 ACT CAT 669 NOW 843 THE 47 IS Shared codes: 2 Sentence: 123! No words
| Variable | Type | Job |
|---|---|---|
KEY | String | keypad digit of each letter |
word | String[] | words of the sentence |
shown | boolean[] | words already printed |
group | String | words with one code |
shared | int | codes with two or more words |
Worth noticing: good, home and gone are all 4663. The array shown stops CAT from being printed a second time after it has appeared beside ACT.
Q3. And when classes are involved?
Set 2 asks for classes with data members and methods, the style in which the subject states most of its programs. The third problem adds an exception class of your own.
A fair share number is divisible by each of its digits, and has no zero among them; 128 is one, since 1, 2 and 8 all divide it. Define a class with the limits of a range (1 to 30000) and methods to test a number and to list the fair share numbers, eight to a line, with their count.
Algorithm in plain steps
import java.util.Scanner;
/* Set 2, Problem 1: numbers divisible by all their digits */
public class FairShare {
private int from, to, found;
FairShare(int from, int to) {
this.from = from;
this.to = to;
found = 0;
}
boolean isFair(int n) {
for (int rest = n; rest > 0; rest /= 10) {
int digit = rest % 10;
if (digit == 0 || n % digit != 0)
return false;
}
return true;
}
void list() {
for (int n = from; n <= to; n++)
if (isFair(n)) {
System.out.print(n + " ");
found++;
if (found % 8 == 0)
System.out.println();
}
if (found % 8 != 0)
System.out.println();
System.out.println("Found " + found);
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("From and to: ");
int a = scan.nextInt(), b = scan.nextInt();
if (a < 1 || b > 30000 || a > b)
System.out.println("Range not allowed");
else
new FairShare(a, b).list();
}
}
From and to: 1 130 1 2 3 4 5 6 7 8 9 11 12 15 22 24 33 36 44 48 55 66 77 88 99 111 112 115 122 124 126 128 Found 30 From and to: 200 210 Found 0 From and to: 9 3 Range not allowed
| Variable | Type | Job |
|---|---|---|
from, to | int | limits of the range |
found | int | numbers printed |
n | int | number being tested, unchanged |
rest | int | copy that loses its digits |
digit | int | digit taken from rest |
Worth noticing: the zero test comes before the division. Written the other way round, 200 would stop the program with an ArithmeticException.
Accept the names and scores of 2 to 20 players. Arrange them in descending order of score with a selection sort and print the ranks. Players with equal scores share a rank, and the rank after a tie is skipped: 1, 1, 3.
Algorithm in plain steps
import java.util.Scanner;
/* Set 2, Problem 2: a rank list in which ties share a rank */
public class RankList {
private String[] name;
private int[] score;
RankList(int n) {
name = new String[n];
score = new int[n];
}
void accept(Scanner scan) {
for (int i = 0; i < name.length; i++) {
System.out.print("Name and score: ");
name[i] = scan.next();
score[i] = scan.nextInt();
}
}
// selection sort, highest first; both arrays move together
void arrange() {
for (int i = 0; i < score.length - 1; i++) {
int top = i;
for (int j = i + 1; j < score.length; j++)
if (score[j] > score[top])
top = j;
int s = score[i];
score[i] = score[top];
score[top] = s;
String n = name[i];
name[i] = name[top];
name[top] = n;
}
}
void display() {
int rank = 1;
for (int i = 0; i < score.length; i++) {
if (i > 0 && score[i] < score[i - 1])
rank = i + 1; // a tie skips ranks
System.out.printf("%d %-8s%d%n",
rank, name[i], score[i]);
}
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("How many (2 to 20): ");
int n = scan.nextInt();
if (n < 2 || n > 20) {
System.out.println("Cannot make a list");
return;
}
RankList r = new RankList(n);
r.accept(scan);
r.arrange();
r.display();
}
}
How many (2 to 20): 5 Name and score: Kabir 71 Name and score: Nisha 88 Name and score: Om 71 Name and score: Rehan 64 Name and score: Sana 88 1 Nisha 88 1 Sana 88 3 Om 71 3 Kabir 71 5 Rehan 64 How many (2 to 20): 1 Cannot make a list
| Variable | Type | Job |
|---|---|---|
name | String[] | names of the players |
score | int[] | scores, same order as names |
top | int | index of the highest so far |
rank | int | rank being printed |
Worth noticing: Kabir was typed before Om, yet Om is printed first. A selection sort may disturb the order of equal items because it exchanges over a distance; an insertion sort would have kept Kabir ahead.
Accept a four digit PIN, with at most three attempts. A PIN is weak if it does not have four characters, carries a sign, has all digits equal, or is a rising run such as 2345. Throw a WeakPinException with the reason. Letters must be caught separately. Every attempt is recorded, whatever happens.
Algorithm in plain steps
import java.util.Scanner;
/* Set 2, Problem 3: a PIN that must obey three rules */
class WeakPinException extends Exception {
private static final long serialVersionUID = 1L;
WeakPinException(String reason) {
super(reason);
}
}
public class PinGuard {
static void check(String pin) throws WeakPinException {
if (pin.length() != 4)
throw new WeakPinException("needs 4 digits");
Integer.parseInt(pin); // fails on a letter
if (!Character.isDigit(pin.charAt(0)))
throw new WeakPinException("no sign allowed");
boolean same = true, run = true;
for (int i = 1; i < 4; i++) {
int gap = pin.charAt(i) - pin.charAt(i - 1);
if (gap != 0)
same = false;
if (gap != 1)
run = false;
}
if (same)
throw new WeakPinException("all digits equal");
if (run)
throw new WeakPinException("digits in a run");
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
for (int attempt = 1; attempt <= 3; attempt++) {
System.out.print("PIN: ");
String pin = scan.next();
try {
check(pin);
System.out.println("PIN accepted");
return;
} catch (WeakPinException e) {
System.out.println("Weak: " + e.getMessage());
} catch (NumberFormatException e) {
System.out.println("Digits only");
} finally {
System.out.println("Attempt " + attempt
+ " recorded");
}
}
System.out.println("Locked");
}
}
PIN: 5555 Weak: all digits equal Attempt 1 recorded PIN: 12a4 Digits only Attempt 2 recorded PIN: 7391 PIN accepted Attempt 3 recorded PIN: 2345 Weak: digits in a run Attempt 1 recorded PIN: +123 Weak: no sign allowed Attempt 2 recorded PIN: 0000 Weak: all digits equal Attempt 3 recorded Locked
| Variable | Type | Job |
|---|---|---|
pin | String | the PIN as typed |
gap | int | difference of neighbouring characters |
same, run | boolean | all equal so far, all rising by 1 |
attempt | int | number of the attempt |
Worth noticing: finally runs even when the try block returns, which is why attempt 3 is recorded after PIN accepted. The sign test is there because parseInt quietly accepts +123.
Q4. Something from hardware and recursion?
The hardware chapters of Section A make good programs, because the rule is already exact. Set 3 has one of those between a recursion problem and a string problem.
Multiply the digits of a number, then the digits of the result, until one digit is left. For each number of a range of at most 21, print the chain, and at the end the number that takes most rounds. Both the product and the rounds must be recursive.
Algorithm in plain steps
import java.util.Scanner;
/* Set 3, Problem 1: multiply the digits until one is left */
public class DigitFall {
// product of the digits of n, recursive
static long product(long n) {
if (n < 10)
return n;
return (n % 10) * product(n / 10);
}
// rounds needed to reach one digit, recursive
static int rounds(long n) {
System.out.print(n);
if (n < 10) {
System.out.println();
return 0;
}
System.out.print(" -> ");
return 1 + rounds(product(n));
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Lower and upper: ");
int a = scan.nextInt(), b = scan.nextInt();
if (a < 10 || b < a || b - a > 20) {
System.out.println("Give at most 21 numbers");
return;
}
int most = -1, holder = 0;
for (int n = a; n <= b; n++) {
int r = rounds(n);
if (r > most) {
most = r;
holder = n;
}
}
System.out.println(holder + " takes most rounds, "
+ most);
}
}
Lower and upper: 75 79 75 -> 35 -> 15 -> 5 76 -> 42 -> 8 77 -> 49 -> 36 -> 18 -> 8 78 -> 56 -> 30 -> 0 79 -> 63 -> 18 -> 8 77 takes most rounds, 4 Lower and upper: 10 12 10 -> 0 11 -> 1 12 -> 2 10 takes most rounds, 1 Lower and upper: 5 8 Give at most 21 numbers
| Variable | Type | Job |
|---|---|---|
n | long | number in the present call |
r | int | rounds taken by one number |
most | int | largest value of r |
holder | int | number that gave it |
Worth noticing: most starts at -1, below any possible result, so the first number always replaces it. 78 ends at 0 as soon as a zero digit appears.
Accept two integers from -128 to 127. Show each in 8 bit two’s complement, add the bit patterns, show the sum and its value, and say whether overflow has occurred.
Algorithm in plain steps
import java.util.Scanner;
/* Set 3, Problem 2: 8 bit two's complement addition */
public class SignedByte {
private int[] bit = new int[8]; // bit[0] is the sign bit
void store(int n) {
boolean negative = n < 0;
int m = Math.abs(n);
for (int i = 7; i >= 0; i--) {
bit[i] = m % 2;
m /= 2;
}
if (negative) { // invert, then add 1
int carry = 1;
for (int i = 7; i >= 0; i--) {
int t = (1 - bit[i]) + carry;
bit[i] = t % 2;
carry = t / 2;
}
}
}
SignedByte add(SignedByte other) {
SignedByte sum = new SignedByte();
int carry = 0;
for (int i = 7; i >= 0; i--) {
int t = bit[i] + other.bit[i] + carry;
sum.bit[i] = t % 2;
carry = t / 2;
}
return sum; // the last carry is dropped
}
int value() { // sign bit weighs -128
int v = -128 * bit[0];
for (int i = 1, w = 64; i < 8; i++, w /= 2)
v += bit[i] * w;
return v;
}
void show(String label) {
System.out.print(label);
for (int i = 0; i < 8; i++)
System.out.print(bit[i]);
System.out.println(" " + value());
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Two numbers: ");
int p = scan.nextInt(), q = scan.nextInt();
if (p < -128 || p > 127 || q < -128 || q > 127) {
System.out.println("Needs more than 8 bits");
return;
}
SignedByte a = new SignedByte(), b = new SignedByte();
a.store(p);
b.store(q);
SignedByte c = a.add(b);
a.show("A ");
b.show("B ");
c.show("Sum ");
if (a.bit[0] == b.bit[0] && c.bit[0] != a.bit[0])
System.out.println("Overflow: not a true sum");
}
}
Two numbers: 45 -72 A 00101101 45 B 10111000 -72 Sum 11100101 -27 Two numbers: 90 60 A 01011010 90 B 00111100 60 Sum 10010110 -106 Overflow: not a true sum Two numbers: -128 -1 A 10000000 -128 B 11111111 -1 Sum 01111111 127 Overflow: not a true sum Two numbers: 200 3 Needs more than 8 bits
| Variable | Type | Job |
|---|---|---|
bit | int[8] | pattern, bit[0] is the sign |
m | int | size of the number while it is divided |
t | int | bits added at one place |
carry | int | carry to the place on the left |
w | int | weight of a bit, 64 down to 1 |
Worth noticing: 90 + 60 is 150, which 8 bits cannot hold, so the pattern reads as -106, exactly 256 less. A positive and a negative number added together can never overflow. More on the theory is in our Boolean algebra page, where adders are built from gates.
Accept words one at a time until a full stop is typed alone. Weld each word to the result at the longest overlap: if the end of the result is also the start of the word, the shared letters are written once. Print the welded word and the number of letters saved.
Algorithm in plain steps
import java.util.Scanner;
/* Set 3, Problem 3: weld two words where they overlap */
public class WordWeld {
// longest end of first that is also the start of second
static int overlap(String first, String second) {
int len = Math.min(first.length(), second.length());
while (len > 0) {
String tail = first.substring(first.length() - len);
if (second.startsWith(tail))
return len;
len--;
}
return 0;
}
static String weld(String first, String second) {
return first
+ second.substring(overlap(first, second));
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Words, then a full stop: ");
String joined = "";
int saved = 0, words = 0;
String w = scan.next().toLowerCase();
while (!w.equals(".")) {
saved += overlap(joined, w);
joined = weld(joined, w);
words++;
w = scan.next().toLowerCase();
}
if (words < 2)
System.out.println("At least two words, please");
else {
System.out.println("Welded : " + joined);
System.out.println("Letters saved: " + saved);
}
}
}
Words, then a full stop: program grammar margin . Welded : programmargin Letters saved: 7 Words, then a full stop: ice east . Welded : iceast Letters saved: 1 Words, then a full stop: solo . At least two words, please
| Variable | Type | Job |
|---|---|---|
joined | String | the word so far |
w | String | word just read |
len | int | overlap being tried |
saved | int | letters written once instead of twice |
Worth noticing: starting from the longest length means the first match is the answer. Starting from 1 would stop at a short overlap and miss a longer one.
Q5. What else belongs in the work file?
Files and packages rarely fit into a ninety minute problem, but they are in Section C and deserve an assignment each. Here is one of every kind.
Create a text file with three days of readings, append a fourth typed by the user, then read the file and list the days above a given number of litres with their count and the total.
Algorithm in plain steps
import java.io.*;
import java.util.Scanner;
import java.util.StringTokenizer;
/* Lab 1: text file, created, appended and searched */
public class WaterLog {
static final String FILE = "water.txt";
// append = false starts a new file
static void write(String line, boolean append)
throws IOException {
PrintWriter out =
new PrintWriter(new FileWriter(FILE, append));
out.println(line);
out.close();
}
static void search(int above) throws IOException {
BufferedReader in =
new BufferedReader(new FileReader(FILE));
String line;
int hits = 0, total = 0;
while ((line = in.readLine()) != null) {
StringTokenizer st = new StringTokenizer(line);
String day = st.nextToken();
int litres = Integer.parseInt(st.nextToken());
total += litres;
if (litres > above) {
System.out.println(" " + day + " " + litres);
hits++;
}
}
in.close();
System.out.println("Days above " + above + ": " + hits);
System.out.println("Total litres: " + total);
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
try {
write("Mon 310", false);
write("Tue 275", true);
write("Wed 402", true);
System.out.print("Day and litres to add: ");
write(scan.next() + " " + scan.nextInt(), true);
System.out.print("Show days above: ");
search(scan.nextInt());
} catch (IOException e) {
System.out.println("File trouble: "
+ e.getMessage());
}
}
}
Day and litres to add: Thu 355 Show days above: 300 Mon 310 Wed 402 Thu 355 Days above 300: 3 Total litres: 1342
| Variable | Type | Job |
|---|---|---|
FILE | String | name of the file |
append | boolean | add to the file or start again |
line | String | line read, null at the end |
litres | int | reading on that line |
hits, total | int | days above the limit, sum |
Worth noticing: the second argument of FileWriter decides between writing and appending. Change the first call to true and the file grows each time you run the program.
Write four records (code, name, height) to a binary file through FileOutputStream. Show the size of the file in bytes, then search it for a code and say how many records were read.
Algorithm in plain steps
import java.io.*;
import java.util.Scanner;
/* Lab 2: binary file of records, written and searched */
public class PlantFile {
static final String FILE = "plants.dat";
static void create() throws IOException {
int[] code = { 105, 108, 121, 134 };
String[] name = { "Neem", "Tulsi", "Areca", "Aloe" };
double[] height = { 62.5, 18.0, 45.5, 12.25 };
DataOutputStream out =
new DataOutputStream(new FileOutputStream(FILE));
for (int i = 0; i < code.length; i++) {
out.writeInt(code[i]);
out.writeUTF(name[i]);
out.writeDouble(height[i]);
}
out.close();
}
// reads records in the order they were written
static void find(int wanted) throws IOException {
DataInputStream in =
new DataInputStream(new FileInputStream(FILE));
int read = 0;
boolean found = false;
try {
while (!found) {
int code = in.readInt();
String name = in.readUTF();
double height = in.readDouble();
read++;
if (code == wanted) {
System.out.println(name + ", " + height
+ " cm");
found = true;
}
}
} catch (EOFException e) {
System.out.println("No plant with that code");
} finally {
in.close();
}
System.out.println("Records read: " + read);
}
public static void main(String[] args) throws IOException {
create();
System.out.println("Size: " + new File(FILE).length()
+ " bytes");
Scanner scan = new Scanner(System.in);
System.out.print("Code: ");
find(scan.nextInt());
}
}
Size: 74 bytes Code: 121 Areca, 45.5 cm Records read: 3 Size: 74 bytes Code: 150 No plant with that code Records read: 4
| Variable | Type | Job |
|---|---|---|
code | int | plant code, 4 bytes |
name | String | plant name |
height | double | height in cm, 8 bytes |
read | int | records read so far |
found | boolean | ends the search early |
Worth noticing: the 74 bytes can be checked: each record is 4 + 8 bytes, plus 2 for the length of the name, plus its letters. Four times 14 is 56, and the names have 18 letters. A text editor shows the same file as nonsense, which is the difference to explain.
Create a package named measure with a class Length in metres and centimetres. In another file import it, accept the width of each window and print the total length of curtain rod.
Algorithm in plain steps
// File measure/Length.java
package measure;
public class Length {
private int cm;
public Length(int metres, int cm) {
this.cm = metres * 100 + cm;
}
public Length plus(Length other) {
return new Length(0, cm + other.cm);
}
public String toString() {
return cm / 100 + " m " + cm % 100 + " cm";
}
}
// File CurtainRod.java, in the folder above measure
import java.util.Scanner;
import measure.Length;
public class CurtainRod {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
Length total = new Length(0, 0);
System.out.print("How many windows: ");
int n = scan.nextInt();
for (int i = 1; i <= n; i++) {
System.out.print("Window " + i + " (m cm): ");
int m = scan.nextInt(), c = scan.nextInt();
total = total.plus(new Length(m, c));
}
System.out.println("Rod needed: " + total);
}
}
How many windows: 3 Window 1 (m cm): 1 85 Window 2 (m cm): 2 40 Window 3 (m cm): 0 95 Rod needed: 5 m 20 cm
| Variable | Type | Job |
|---|---|---|
cm | private int | length in centimetres |
total | Length | sum so far |
n | int | number of windows |
m, c | int | one window, metres and cm |
Worth noticing: toString() is called when an object is joined to text, so the last line prints 5 m 20 cm. Without public on the constructor, the file outside the package would not compile.
Q6. Twenty assignments and a project?
The assignments are short programs kept in a work file, at least twenty in the year. The project is one larger piece on any topic of the syllabus, and it can be a presentation, a model or an application.
Base addition, seat block, keypad codes, fair share numbers, rank list, PIN exception, digit products, two’s complement, welded words, text file, binary file, package. Rewrite each with your own story and data.
Decimal to any base and back; a real number as mantissa and exponent; Unicode value of typed characters; roots of a quadratic with complex roots reported; insertion sort with each pass shown; a merge of two sorted arrays; replacing a word throughout a sentence; HCF by recursion.
The list of projects suggested in the document ranges from expert systems (traffic routing, symptoms and treatment, age checks on social media), through Arduino models (an adder, a binary to decimal converter), to console applications in Java: cinema booking, coding and decoding a message, finding a bank branch from its IFSC, a direct tax calculator and a small text editor. They are suggestions, so any idea tied to the syllabus may be proposed to your teacher.
Suppose the idea is a bus pass desk: students are issued passes for a route, passes are renewed and expired ones are listed. This is how it looks on one page before any code is written.
| Part | Decision | Syllabus topic shown |
|---|---|---|
| Data | Class Pass: pass number, name, route, months left | Objects, constructors, this |
| Storage | Array of Pass while running, text file between runs | Arrays, file handling |
| Operations | Issue, renew, search by number, list by route, end of month | Methods, searching, sorting |
| Rules | A pass lasts 1 to 12 months; a route has at most 40 passes | Exceptions, validation |
| Screen | A menu that repeats until Exit | switch, do while, Scanner |
| Proof | Ten test cases with expected and actual result | Debugging, documentation |
Three other starting points in the same spirit: a library shelf finder that stores books in a binary file, a relay race timer that ranks teams with ties, and a base converter that shows every carry. Five marks do not need a thousand lines. They need a topic you can defend.
Read all three problems of a set and write the hardest step of each in six words. Attempt the one where those six words are clear.
Algorithm, then Java by hand, within 90 minutes. A program you cannot write without autocomplete is a program you have not learnt yet.
Type what you wrote. Mark each correction in another colour; the list of corrections is your revision list.
Let someone else choose three inputs. Zero, one, equal values and the very last legal value find most faults.
In Class 12 the count rises to twenty-five and the project disappears, as our Class 12 work file plan shows, and the topics are listed in the ISC 2027 syllabus. For more single programs, see Java programs for ISC Class 11 and 12 on the blog.
One to one, at your own timing
Try first. The priority demo is a full live class you pay for and schedule yourself; it ends with a written skill report, and its fee is adjusted in your first month if you enrol. If you would rather begin with the free demo class, that is open too. Classes are then personalised one to one, with monthly billing and no admission fee.
Before you enrol · Try a class
a full live class of about 45 to 60 minutes
The classes · Choose your own timing
₹4,999
per month, 4 private classes, fully flexible timingtwo private classes a week, at a time set with you
Two years of ISC Computer Science rest on Class 11: recursion, arrays and classes all return in harder forms. A student who finishes this year comfortable with a blank screen has the easier Class 12. Fees are monthly, shown above for your region, and you may stop at the end of any month.
Studying ISC abroad
Schools in the UAE, Singapore, Indonesia and Thailand that follow ISC run the same Class 11 practical themselves. Lessons are private, so the hour is simply the one that suits your evening.
| Where you live | Time difference | Usual class window, local time | Format |
|---|---|---|---|
| India every Indian city | Indian time | Any time you choose | Personalised 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 |
Assignment and project dates come from your school. Bring them to the demo and the year is planned around them. Regular teaching of the subject is described on ISC Class 11 Computer Science classes.
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 ISC Class 11 and 12 series
Every page in the ISC Computer Science (868) series, grouped by what you need.
CBSE Class 12 Computer Science (083): Class 12 CS viva questions Class 12 CS sample paper practice Class 12 CS project with source code Class 12 CS important questions
CBSE Class 12 Informatics Practices (065): Class 12 IP practical file Class 12 IP project with source code Class 12 IP sample paper practice Class 12 IP important questions
CBSE Class 12 Information Technology (802): IT 802 practical and project file IT 802 Java notes and programs IT 802 notes
CBSE Class 11 CS, IP and AI: Class 11 CS practical file Class 11 IP practical file CS or IP in Class 11
Program lists with output: Java programs for ISC Class 11 and 12 String and array programs in Java
Class 11 questions
Three programming problems in Java, of which you attempt one. You plan on paper for up to 90 minutes, writing an algorithm and a program by hand, and then have up to 90 minutes to key it in and run it on seen and unseen inputs. The school evaluates it.
Thirty marks in the ISC 2027 document: 15 for the problem solved on the computer, 10 for the programming assignments of the year and 5 for one project. Theory is 70 marks, which makes a total of 100.
Students are expected to do a minimum of twenty assignments in the year and one project based on the syllabus. In Class 12 the minimum is twenty-five and no project is listed.
It has three sections: A on number systems, encodings, logic and gates; B on Java, from objects and exceptions to arrays and strings; C on input and output, data files, recursion, packages, trends and ethics. That is the Class XI text of the ISC 2027 document.
Your ISC examination is in 2028, so the 2028 document is the one that binds you. The facts on this page come from the Class XI text of the ISC 2027 document, the latest one we could read. Use it to practise, and ask your school for the 2028 syllabus to confirm marks and topics.
Yes. The Class XI syllabus lists the concept of recursion and simple recursive methods, with factorial, GCD, binary search and conversion between bases as examples. It returns in Class 12 with harder problems, so learn to state the base case first.
Both are in Section C of Class XI in the 2027 document. Files include text and binary, with byte streams such as FileInputStream and character streams such as FileReader, and the operations of creating, reading, writing, appending and searching. Packages include creating and importing your own.
Pick a topic you can explain without notes. The document suggests expert systems, Arduino models and console applications in Java, and allows any topic from the syllabus. A console program with a clear class, a file and ten test cases is safer than a large idea left half finished.
Class 11 papers are set by schools, so there is no single board paper to download. For the practical, the three sets on this page follow the pattern of three problems. For theory, ask your teacher for past school papers and practise each section of the syllabus.
Schools decide admission to the subject. On content, the Class XI syllabus introduces object oriented programming, variables and loops from the start, so it can be learnt fresh, though a student new to Java needs extra practice in the first two months.
Java 5.0 or later with any editor. The syllabus strongly recommends BlueJ because it is simple and suits starting with objects, and it names Eclipse and NetBeans too. The programs on this page compile with plain javac, and the package program needs only a folder named measure.
Yes, as personalised one to one classes at days and hours you choose. The student writes the programs and the project; the teacher explains, questions and checks. You can book a priority demo at your own slot, or begin with the free demo class.
Start
Let your child choose any problem of Set 1 and try it on paper this week. Bring the sheet, finished or not, to the demo class: we read the plan together, type it, and find the first line that goes wrong.
Families who want a fixed slot and a written result can book the priority demo. Its fee is adjusted against the first month when you enrol, and the skill report is yours either way.
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