Back to the 2026 paper

Module 2: Arrays and Strings

20262m

A constructor is automatically invoked when:

(i) A method is called
(ii) A package is imported
(iii) An object is created
(iv) A class is inherited

Worked SolutionAI Assisted

Answer: (iii) An object is created

A constructor runs when an object is instantiated with new (or through another constructor). It initializes the new object's state. Constructors have the class name and no return type.

class Student {
    Student() { System.out.println("Created"); }
}
Student s = new Student(); // invokes constructor

Similar questions

Student FinanceWeb Platform

Pocketly — Personal Finance for Students

Keep your hostel and college expenses under control. Track accounts, log spending in seconds, and stay within your monthly budget.