A Java constructor shares the exact class name, carries no return type—not even `void`—and runs automatically when `new` creates an object to initialize instance variables. Methods perform actions on existing objects, must declare a return type, and execute only when explicitly called. Java supplies a silent non-parameterized default constructor only when zero constructors are coded. Defining multiple constructors with distinct parameter counts or data types enables constructor overloading for flexible object initialization.
- 1. Core Syntax Rules Separating Constructors from Methods
- 2. Default, Non-Parameterized, Parameterized, and Copy Constructors
- 3. Constructor Overloading Signatures & Chaining with this()
- 4. Overloaded Constructors & Methods in ICSE Class Design
- 5. CISCE Variable Description Table (VDT) & Dry Run
- 6. Common Mistakes & Top Scorer Tips
- 7. Interactive Concept Check Quiz
- 8. Frequently Asked Questions
1. Core Syntax Rules Separating Constructors from Methods
In ICSE Section A comparison tables and Section B class-design questions, examiners test four structural rules of constructors. First, the constructor identifier must match the enclosing class spelling and capitalization identically. Second, adding `void` in front of `Student()` silently turns it into a regular method, so `new Student()` no longer invokes it. Third, constructors cannot be marked `static`, `final`, or `abstract`, though they commonly use `public` access. Fourth, a constructor is invoked implicitly once per `new` expression, whereas a method can be called repeatedly through the object reference using dot notation. Inside a constructor, `this` resolves shadowing when parameters share instance variable names.
- Constructor name matches the class name; method names follow camelCase verbs like compute().
- Writing void Book() creates a method, leaving Book's instance fields uninitialized at construction.
- Constructors run automatically via new; methods require explicit calls like obj.display().
2. Default, Non-Parameterized, Parameterized, and Copy Constructors
CISCE textbooks classify constructors into four distinct forms you must identify by definition and snippet. A compiler-provided default constructor exists solely when you write no constructor in the class, setting numeric fields to `0`, `boolean` to `false`, and `String` to `null`. A user-defined non-parameterized constructor takes empty parentheses `()` and assigns custom starting values like `rate = 5.5`. A parameterized constructor accepts arguments to customize each new object immediately. Finally, a copy constructor takes another object of the same class (`Book(Book other)`) and duplicates its field values safely into the newly allocated instance.
- Once you define any parameterized constructor, Java stops generating the zero-arg default constructor.
- Calling new Item() after writing only Item(int p) triggers a no-suitable-constructor error.
- Always pass objects into a copy constructor to clone state without sharing object references.
3. Constructor Overloading Signatures & Chaining with this()
Constructor overloading allows a single class to expose multiple constructors differentiated strictly by their parameter lists—either the number of parameters, their data types, or the sequence of distinct types. Changing only parameter variable names such as `Box(int a)` and `Box(int b)` produces a duplicate-constructor compile error. Inside an overloaded constructor, calling `this(args)` as the very first executable statement delegates initialization to another constructor in the same class, preventing repeated assignment logic. In 15-mark ICSE Section B questions, write the specified default constructor first, add the overloaded parameterized constructor if requested, and verify `main()` tests both.
- Valid overload signatures: Box(), Box(int s), Box(double s), Box(int l, double w).
- this(...) must appear on line 1 inside the constructor body or Java rejects it.
- Do not re-declare instance variables inside the constructor body—assign directly to the class fields.
4. Overloaded Constructors & Methods in ICSE Class Design
import java.util.*;
public class ParcelBill {
private String itemCode;
private double weightKg;
private double charge;
// Non-parameterized constructor
public ParcelBill() {
itemCode = "STD-00";
weightKg = 1.0;
charge = 0.0;
}
// Parameterized constructor
public ParcelBill(String itemCode, double weightKg) {
this.itemCode = itemCode;
this.weightKg = weightKg;
this.charge = 0.0;
}
// Copy constructor
public ParcelBill(ParcelBill other) {
this.itemCode = other.itemCode;
this.weightKg = other.weightKg;
this.charge = other.charge;
}
// Method (explicit return type void)
public void calculate() {
if (weightKg <= 2.0) {
charge = 50.0;
} else {
charge = 50.0 + (weightKg - 2.0) * 18.0;
}
}
public void display() {
System.out.println(itemCode + " | " + weightKg + " kg | Rs." + charge);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter item code and weight (kg): ");
String code = sc.next(); // Sample input: EXP-12
double wt = sc.nextDouble(); // Sample input: 4.5
ParcelBill p1 = new ParcelBill();
ParcelBill p2 = new ParcelBill(code, wt);
p1.calculate();
p2.calculate();
ParcelBill p3 = new ParcelBill(p2);
p1.display();
p2.display();
p3.display();
sc.close();
}
}
Verified Console / Dry-Run Output:
Enter item code and weight (kg): EXP-12 4.5
STD-00 | 1.0 kg | Rs.50.0
EXP-12 | 4.5 kg | Rs.95.0
EXP-12 | 4.5 kg | Rs.95.0
5. CISCE Variable Description Table (VDT) & Dry Run
| Variable | Data Type | Exam Purpose & Sample Value |
|---|---|---|
| itemCode | String | Instance field storing parcel tag ("STD-00" / "EXP-12") |
| weightKg | double | Instance field holding parcel weight in kg (1.0 / 4.5) |
| charge | double | Computed shipping fee calculated by calculate() (50.0 / 95.0) |
| code | String | Scanner input passed into parameterized constructor ("EXP-12") |
| wt | double | Scanner weight input passed to ParcelBill(code, wt) (4.5) |
| p1, p2, p3 | ParcelBill | Objects testing non-parameterized, parameterized, and copy constructors |
Build Clean Section B Class Programs in Live 1-on-1 Sessions
Practice constructor overloading, object creation, and BlueJ debugging live with an ICSE mentor on real board-pattern class designs.
6. Common Mistakes & Top Scorer Tips
- Avoid Mistake: Writing public void ParcelBill() by habit, turning the constructor into an uncalled method.
- Avoid Mistake: Declaring local variables like double weightKg = wt; inside the constructor, leaving instance fields at 0.0.
- Avoid Mistake: Calling new ParcelBill() after writing only ParcelBill(String, double) without adding a zero-argument constructor.
- Examiner / Mentor Tip: State at least two structural differences (return type and invocation timing) for 2-mark Section A questions.
- Examiner / Mentor Tip: Always use this.field = field; whenever constructor parameter names match instance variables.
- Examiner / Mentor Tip: Verify that your Section B class implements every constructor signature named in the question prompt.
7. Interactive Concept Check Quiz
Question: Which statement about Java constructors is FALSE for ICSE Board exams?
8. Frequently Asked Questions
What happens if I declare a parameterized constructor without a default constructor?
Why does BlueJ show an uninitialized 0 or null when I add void to my constructor?
Can a Java constructor call another method or constructor inside the same class?
Explore Related Lessons & Free Interactive Tools
- All 110 Guides in ICSE Java BlueJ Library
- Java Access Specifiers (public, private, protected) & static/final
- ICSE 100/100 Blueprint: VDT, Comments & BlueJ Board Rules
- Niven (Harshad) Number Program in Java for ICSE Class 10
- Interactive Tool: ICSE Class 10 Java BlueJ Output Quiz
- Interactive Tool: ICSE Variable Description Table (VDT) Auto-Formatter
