Skip to content
Computer ApplicationsICSE Class 10 · Chapter 12

Constructors ICSE Class 10 Computer Applications

Updated 14 October 2026 · Fact-checked

A constructor is a special member of a class with the same name as the class and no return type, called automatically when an object is created with new, to initialise its member variables. It may be default (no-argument) or parameterised, and a class can have overloaded constructors. ICSE Class 10 also asks how constructors differ from methods.

What Constructors is about

Constructors decide the starting values of every object. Board questions are short and precise: the possible name of a constructor for class Yellow (2024), the output of a class with two constructors (2024 temp, 2025 report), and the statement creating an object whose constructor takes three double values (2025). Examiners noted case errors in constructor names, outputs written in the wrong order, and missing arguments in object creation.

The syllabus asks for the definition and characteristics of constructors, their types (default and parameterised), their use, constructor overloading, and the difference between a constructor and a method.

Weightage: CISCE publishes no chapter weightage. Section A (40 marks) is compulsory: 1-mark MCQs and 2-mark short answers including output and error questions; in Section B you answer any four of six 15-mark programming questions written in Java.Source: CISCE ICSE Computer Applications (661) specimen paper structure for 2027

Key concepts

Definition and characteristics

A constructor is a special member method used to initialise the member variables of an object when it is created.

Characteristics:
(1) Its name is exactly the same as the class name (case sensitive: for class Yellow, the constructor is Yellow).
(2) It has no return type, not even void.
(3) It is called automatically when an object is created with new; it cannot be called like an ordinary method.
(4) It is usually declared public so objects can be created from anywhere.
(5) It can be overloaded (several constructors with different parameter lists).
(6) If a class has no constructor, Java supplies an invisible default constructor that sets members to default values (0, 0.0, false, null).

class Student
{
String name;
int marks;
Student()
{
name = "Unknown";
marks = 0;
}
}

Worked example

(1 mark) If the name of the class is Yellow, a constructor can be named:
(a) yellow
(b) YELLOW
(c) Yell
(d) Yellow

Try it first, then show the solutionSolution
  1. The constructor name must match the class name exactly, including case.

Answer: (d) Yellow

Default (non-parameterised) constructor

A default constructor takes no parameters. It gives the same starting values to every object.

class Lamp
{
int watts;
Lamp()
{
watts = 60;
}
}
Lamp a = new Lamp(); → a.watts is 60.

If the programmer writes no constructor at all, Java provides an implicit default constructor that sets members to 0, 0.0, false or null. But once the programmer writes any constructor (for example a parameterised one), Java no longer supplies the default one; then new Lamp() is an error unless a no-argument constructor is written too.

Worked example

(2 marks) class Pen { int ink; Pen(int i) { ink = i; } } Why does Pen p = new Pen(); fail to compile? Fix it.

Try it first, then show the solutionSolution
  1. Once a parameterised constructor is written, Java does not supply a default constructor - 1 mark.
  2. Add Pen() { ink = 100; } or call new Pen(100) - 1 mark.

Answer: There is no no-argument constructor, because writing Pen(int i) removes the implicit default one. Fix: add Pen() { ink = 100; } to the class, or create the object with new Pen(100).

Parameterised constructor

A parameterised constructor takes arguments, so each object can be given its own starting values at creation.

class Rect
{
int l, b;
Rect(int x, int y)
{
l = x;
b = y;
}
}
Rect r = new Rect(5, 3); → l = 5, b = 3.

The arguments in the new statement must match the constructor's parameters in number, type and order: an object sifra of class Robot whose constructor takes three double values is created as Robot sifra = new Robot(2.5, 1.0, 0.75);

Worked example

(2 marks) Write the statement to create an object sifra of class Robot whose constructor takes three double parameters.

Try it first, then show the solutionSolution
  1. Class name on both sides, object name sifra, new - 1 mark.
  2. Three double arguments in the brackets - 1 mark.

Answer: Robot sifra = new Robot(2.5, 1.0, 0.75);

Constructor overloading

Constructor overloading means having more than one constructor in a class, each with a different parameter list. Java calls the one whose parameters match the arguments given with new.

class report
{
int a, b;
report()
{
a = 10; b = 15;
}
report(int x, int y)
{
a = x; b = y;
}
void print()
{
System.out.println(a * b);
}
static void main()
{
report r = new report();
r.print();
report p = new report(4, 5);
p.print();
}
}
Output (in order of the calls):
150
20

Worked example

(2 marks) Give the output:
class temp
{
int a;
temp() { a = 10; }
temp(int z) { a = z; }
void print() { System.out.println(a); }
void main()
{
temp t = new temp();
temp x = new temp(30);
t.print();
x.print();
}
}

Try it first, then show the solutionSolution
  1. t uses the default constructor: a = 10; x uses temp(int): a = 30 - 1 mark.
  2. t.print() then x.print() - 1 mark.

Answer: 10
30

Constructor vs method

(1) Name: a constructor has the same name as the class; a method can have any valid name.
(2) Return type: a constructor has none (not even void); a method must have one (void or a type).
(3) Calling: a constructor is called automatically when an object is created with new; a method is called explicitly, as ob.method().
(4) Purpose: a constructor initialises a new object; a method performs operations (behaviour).
(5) Number of calls: a constructor runs once per object, at creation; a method can be called any number of times.
(6) Default: Java supplies a default constructor if none is written; it never supplies methods.

Worked example

(2 marks) Write two differences between a constructor and a method.

Try it first, then show the solutionSolution
  1. Constructor: same name as class, no return type; method: any name, has a return type - 1 mark.
  2. Constructor runs automatically at object creation; method is called explicitly - 1 mark.

Answer: (1) A constructor has the same name as its class and no return type, whereas a method can have any name and must have a return type (void or a data type). (2) A constructor is invoked automatically when an object is created with new, whereas a method is called explicitly through an object or the class.

Constructors in real life

Each concept, met in an everyday situation. Read the situation, answer the question in your own words, then compare with the model answer. The one-line hook is what to remember.

Constructor initialises an object

Suppose every new phone from a factory is switched on for the first time with battery at 50%, language set to English and no contacts.

What part of a Java class does this factory setting resemble?

Try it first, then show the solutionSolution
  1. Starting values are set once, automatically, when the object is made.
  2. That is a constructor's job.
  3. Phone() { battery = 50; language = "English"; contacts = 0; }

Answer: A default constructor that sets the starting state of every new Phone object.

Memory hook: Factory settings = constructor.

Parameterised constructor

Imagine ordering a custom T-shirt where you choose size and colour at the time of ordering.

How does this resemble a parameterised constructor?

Try it first, then show the solutionSolution
  1. Each T-shirt object is created with values you supply.
  2. new TShirt("M", "Blue") passes them to the constructor.
  3. Different orders give different objects.

Answer: Values supplied at creation are like arguments to a parameterised constructor: TShirt(String size, String colour).

Memory hook: Choose at creation = parameterised.

Constructor overloading

Suppose a pizza shop lets you order 'a regular pizza' (default toppings) or 'a pizza with these toppings and this size'.

Which constructor feature does this represent?

Try it first, then show the solutionSolution
  1. Two ways of creating the same kind of object.
  2. Pizza() and Pizza(String toppings, String size).
  3. Java chooses by the arguments.

Answer: Constructor overloading: the class has both a default and a parameterised constructor.

Memory hook: Many ways to be born, same class.

Topics in this chapter

Constructors: syntax and key facts

Constructor syntax
ClassName(parameters) { initialise members; }
No return type, not even void.
Object creation
ClassName ob = new ClassName(arguments);
Arguments choose which constructor runs.
Types
Default (no arguments) and parameterised; overloading = several with different parameter lists
Writing any constructor removes Java's implicit default.

How the board asks Constructors

The question patterns to expect, and the method that works for each.

Question typeHow it is askedMethod
MCQ (Section A)Possible constructor name for class Yellow (2024).Exact same spelling and case as the class.
Output / statement (2 marks)Output of a class with overloaded constructors (2024, 2025); statement to create an object with a three-double constructor (2025).Match each new with its constructor; print in the order of the calls.
Program (15 marks)A class with a parameterised (and default) constructor, calculation and display methods.Initialise all members in the constructor; create objects with arguments in main().

Tricks to remember Constructors

Short memory aids. Say each one aloud once, then use it on a question the same day.

  • SNAP

    Same name as class, No return type, Automatic call, Purpose: initialise.

    Use it when: Characteristics of constructors.

  • Write one, lose the free one

    Once you write any constructor, Java stops giving the free default constructor.

    Use it when: Errors with new ClassName().

Constructors: board-level solved questions

Ordered from board level to HOTS. Cover the solution, write your own, then compare step by step.

Example 1: Return type · 1 mark · MCQBoard level

Which is a correct constructor for class Book?
(a) void Book() { }
(b) Book() { }
(c) int Book() { return 0; }
(d) book() { }

Try it first, then show the solutionSolution
  1. No return type, same name and case: Book().

Answer: (b) Book() { }

Example 2: Assertion and reason: default constructor · 1 mark · Assertion-reasonHOTS / competency

Assertion (A): Java supplies a default constructor for every class.
Reason (R): A constructor initialises the member variables of an object.
(a) Both A and R are true and R is the correct explanation of A
(b) Both A and R are true but R is not the correct explanation of A
(c) A is true but R is false
(d) A is false but R is true

Try it first, then show the solutionSolution
  1. A is false: Java supplies one only if the class has no constructor at all.
  2. R is true.

Answer: (d) A is false but R is true

Example 3: Overloaded constructors output · 2 marks · Very short answerHarder board level

Give the output of the report class (report() sets a = 10, b = 15; report(int x, int y) sets a = x, b = y; print() prints a * b) when main creates r = new report(); r.print(); then p = new report(4, 5); p.print();

Try it first, then show the solutionSolution
  1. r: 10 × 15 = 150, printed first.
  2. p: 4 × 5 = 20, printed second.

Answer: 150
20

Example 4: Three constructors · 2 marks · Short answerHarder board level

Give the output:
class Box
{
int l, b;
Box() { l = 2; b = 3; }
Box(int x) { l = x; b = x; }
Box(int x, int y) { l = x; b = y; }
int area() { return l * b; }
public static void main(String args[])
{
Box p = new Box();
Box q = new Box(4);
Box r = new Box(5, 2);
System.out.println(p.area() + q.area() + r.area());
}
}

Try it first, then show the solutionSolution
  1. p: 2 × 3 = 6; q: 4 × 4 = 16; r: 5 × 2 = 10.
  2. Numeric addition: 6 + 16 + 10 = 32.

Answer: 32

Example 5: Spot the errors · 2 marks · Very short answerHarder board level

Find and correct two errors:
class Circle
{
double r;
void Circle(double x)
{
r = x;
}
public static void main(String args[])
{
Circle c = new circle(3.5);
}
}

Try it first, then show the solutionSolution
  1. void makes Circle(double) an ordinary method, not a constructor; remove void.
  2. new circle must be new Circle (case).

Answer: Correct: Circle(double x) { r = x; } and Circle c = new Circle(3.5);

Example 6: Employee salary (Section B) · 15 marks · Long answerHarder board level

Define a class Employee with member variables name (String), basic, da, hra and gross (double). Write a default constructor that sets name to "" and the numbers to 0, a parameterised constructor Employee(String n, double b), void compute() where da = 50% of basic, hra = 20% of basic and gross = basic + da + hra, and void display(). Write main() to create an employee Ravi with basic ₹20,000 and display the details.

Try it first, then show the solutionSolution
  1. class Employee
    {
    String name;
    double basic, da, hra, gross;
    Employee()
    {
    name = "";
    basic = da = hra = gross = 0;
    }
    Employee(String n, double b)
    {
    name = n;
    basic = b;
    }
  2. void compute()
    {
    da = basic * 50 / 100;
    hra = basic * 20 / 100;
    gross = basic + da + hra;
    }
  3. void display()
    {
    System.out.println("Name: " + name);
    System.out.println("DA: " + da + " HRA: " + hra);
    System.out.println("Gross: " + gross);
    }
  4. public static void main(String args[])
    {
    Employee e = new Employee("Ravi", 20000);
    e.compute();
    e.display();
    }
    }
  5. Trace: da = 10000.0; hra = 4000.0; gross = 34000.0. (The int 20000 is widened to double b.)

Answer: Output:
Name: Ravi
DA: 10000.0 HRA: 4000.0
Gross: 34000.0

Example 7: Library fine with constructor · 15 marks · Long answerHOTS / competency

Define a class Library with members title (String), days (int, days late) and fine (double). A parameterised constructor sets title and days. void calcFine() charges ₹2 per day for the first 5 days late, ₹5 per day for the next 5 days and ₹10 per day after that. void show() prints title, days and fine. Create two objects in main(): ("Kim", 4) and ("Ivanhoe", 13).

Try it first, then show the solutionSolution
  1. class Library
    {
    String title;
    int days;
    double fine;
    Library(String t, int d)
    {
    title = t;
    days = d;
    }
  2. void calcFine()
    {
    if (days <= 5)
    fine = days * 2;
    else if (days <= 10)
    fine = 5 * 2 + (days - 5) * 5;
    else
    fine = 5 * 2 + 5 * 5 + (days - 10) * 10;
    }
  3. void show()
    {
    System.out.println(title + " " + days + " " + fine);
    }
    public static void main(String args[])
    {
    Library a = new Library("Kim", 4);
    Library b = new Library("Ivanhoe", 13);
    a.calcFine(); a.show();
    b.calcFine(); b.show();
    }
    }
  4. Trace Kim, 4 days: 4 × 2 = 8 → 8.0.
  5. Trace Ivanhoe, 13 days: 10 + 25 + 3 × 10 = 65 → 65.0.

Answer: Output:
Kim 4 8.0
Ivanhoe 13 65.0

Case-study practice (Section B style)

Read the situation, then answer every part. In the board paper this is a 10-mark question split into 2 + 3 + 5 marks.

The cricket score class

Imagine a class Player with members name and runs. Ananya writes Player() { runs = 0; } and Player(String n, int r) { name = n; runs = r; }. In main() she writes Player p1 = new Player(); Player p2 = new Player("Rohit", 54); and later adds void Player(int r) { runs = r; } thinking it is a third constructor.

  1. (i) · 2 marks

    Which constructor runs for p1 and for p2? What is p1.name?

    Answer

    Answer: p1: the default constructor Player(); p2: the parameterised Player(String, int). p1.name is null because the default constructor does not set it.

    1 mark each.

  2. (ii) · 3 marks

    Is void Player(int r) a constructor? Explain.

    Answer

    Answer: No. Because it has a return type (void), it is an ordinary method that happens to share the class name. It is not called by new; it must be called as p1.Player(30).

    Answer 1 mark; reason 2 marks.

  3. (iii) · 5 marks

    Write a proper third constructor taking only runs, and state two differences between constructors and methods.

    Answer

    Answer: Player(int r) { name = "Unknown"; runs = r; } Differences: (1) a constructor has no return type, a method has one; (2) a constructor is invoked automatically by new, a method is called explicitly.

    Constructor 3 marks; differences 1 mark each.

Where the marks are

How a typical answer is split into step marks. Show every step: a right final answer alone rarely earns full marks.

Give the output of a class with overloaded constructors. (2 marks) (2 marks)

StepMarks
Correct constructor matched to each object.1
Outputs in the order of the print calls.1

Class with default and parameterised constructors, compute and display (Employee). (15 marks) (15 marks)

StepMarks
Class and member variables.2
Default constructor initialising all members.2
Parameterised constructor assigning arguments.3
compute() with correct formulas.3
display() with labels.2
main(): object with arguments; method calls.3

Where students lose marks in Constructors

The slips examiners see most often, and what to write instead.

  • Mistake: Wrong case in constructor name

    The 2024 examiners reported confusion over case (yellow vs Yellow) and unclear capital letters.

    Do this: Write the class name exactly, with a clear capital letter.

    Usually costs: 1 mark.

  • Mistake: Outputs in reverse order

    In 2025 candidates wrote 20 before 150 for the report class.

    Do this: Print in the order of the method calls in main().

    Usually costs: 1 mark.

  • Mistake: Skipping one of the print calls

    In 2024 some gave only x.print()'s output for the temp class.

    Do this: Trace every call in main().

    Usually costs: 1 mark.

  • Mistake: Omitting constructor arguments

    In 2025 candidates left out the three double arguments when creating sifra.

    Do this: Match the constructor's parameter list in new ClassName(...).

    Usually costs: 1 mark.

  • Mistake: Giving a constructor a return type

    void Name() turns it into an ordinary method.

    Do this: Constructors never have a return type.

    Usually costs: 1 to 2 marks.

Practice questions on Constructors

Write each answer on paper first. Open the hint only if you are stuck, and the answer only when you have finished.

  1. Q1 · 1 mark · MCQBoard level

    A constructor is invoked:
    (a) when the class is compiled
    (b) when an object is created
    (c) only when called by name
    (d) at the end of the program

    Hint

    new.

    Answer

    (b) when an object is created

  2. Q2 · 1 mark · MCQBoard level

    The return type of a constructor is:
    (a) void
    (b) int
    (c) the class name
    (d) none

    Hint

    Not even void.

    Answer

    (d) none

  3. Q3 · 2 marks · Very short answerBoard level

    Define constructor overloading with an example.

    Hint

    Several constructors.

    Answer

    Constructor overloading is having more than one constructor in a class with different parameter lists, e.g. Point() { x = 0; y = 0; } and Point(int a, int b) { x = a; y = b; }; the arguments in new decide which one runs.

  4. Q4 · 2 marks · Very short answerBoard level

    Write a statement creating an object k of class Kite whose constructor takes a String colour and an int length.

    Hint

    Order of arguments.

    Answer

    Kite k = new Kite("Red", 75);

  5. Q5 · 2 marks · Short answerHOTS / competency

    Give the output:
    class N
    {
    int v;
    N() { v = 1; }
    N(int a) { v = a * a; }
    void add(N o) { v = v + o.v; }
    public static void main(String args[])
    {
    N x = new N(3);
    N y = new N();
    x.add(y);
    y.add(x);
    System.out.println(x.v + " " + y.v);
    }
    }

    Hint

    Order matters.

    Answer

    10 11 (x.v = 9 + 1 = 10; then y.v = 1 + 10 = 11)

  6. Q6 · 2 marks · Very short answerHarder board level

    What does an implicit default constructor do?

    Hint

    Default values.

    Answer

    When a class has no constructor, Java supplies one with no parameters that initialises the member variables to default values: 0 for numbers, 0.0 for decimals, false for boolean and null for objects such as String.

  7. Q7 · 15 marks · Long answerHarder board level

    Define a class Interest with members p, r, t and si (double). Write a parameterised constructor to set p, r and t, void calc() to compute simple interest si = p × r × t / 100, and void show() to print all. Create an object with p = 5000, r = 8, t = 3 in main().

    Hint

    Constructor sets inputs.

    Answer

    class Interest
    {
    double p, r, t, si;
    Interest(double a, double b, double c)
    {
    p = a;
    r = b;
    t = c;
    }
    void calc()
    {
    si = p * r * t / 100;
    }
    void show()
    {
    System.out.println("P = " + p + ", R = " + r + ", T = " + t);
    System.out.println("SI = " + si);
    }
    public static void main(String args[])
    {
    Interest ob = new Interest(5000, 8, 3);
    ob.calc();
    ob.show();
    }
    }
    Output:
    P = 5000.0, R = 8.0, T = 3.0
    SI = 1200.0

  8. Q8 · 2 marks · Short answerHOTS / competency

    Can a constructor be private? What would happen to new from another class?

    Hint

    Access specifiers.

    Answer

    Yes, a constructor can be private, but then objects cannot be created with new from another class; only code inside the class can create them. That is why constructors are usually public.

  9. Q9 · 2 marks · Very short answerBoard level

    State two characteristics of a constructor.

    Hint

    SNAP.

    Answer

    (1) It has the same name as the class. (2) It has no return type, not even void (also: it is called automatically when an object is created).

Test your recall

Answer in your head or on paper first, then open the card. Pulling an answer out of memory makes it stick far better than re-reading.

  1. 1.Constructor name rule?Show answer

    Same as the class name, same case.

  2. 2.Return type of a constructor?Show answer

    None, not even void.

  3. 3.Two types of constructors?Show answer

    Default (no-argument) and parameterised.

  4. 4.When does Java supply a default constructor?Show answer

    Only when the class has no constructor at all.

  5. 5.What decides which overloaded constructor runs?Show answer

    The arguments given with new.

Best order to study it

  1. Definition and characteristics.
  2. Default and implicit default constructors.
  3. Parameterised constructors and object creation statements.
  4. Constructor overloading and output tracing.
  5. Constructor vs method.
  6. Write one full class with constructors.

Quick revision checklist

The night before the exam: can you do each of these without looking?

  • Constructor: same name as class, no return type, automatic with new, initialises members.
  • Default: no parameters; Java gives one only if none is written.
  • Parameterised: values passed in new ClassName(args).
  • Overloading: several constructors, different parameter lists.
  • Method: any name, return type, called explicitly, any number of times.

Constructors: frequently asked questions

Can a constructor call a method?

Yes, a constructor can call other methods of the class while initialising the object.

Is 'this' in the syllabus?

It is not named in the syllabus; using different parameter names (as on this page) avoids needing it.

Can a constructor be static?

No. Constructors belong to objects being created, so they cannot be static.

Based on: CISCE ICSE 2027 Computer Applications syllabus; CISCE Analysis of Pupil Performance ICSE 2025: Computer Applications (with the 2025 board paper)