oop

3. The 'super' Keyword: Constructor Chaining

Analyze the code, write your predicted output, and then reveal the solution.

Scenario

Understand how to pass parameters from a child constructor to a parent constructor using super().

Code Block
class Employee { String name; Employee(String name) { this.name = name; System.out.println("Employee initialized: " + name); } } class Developer extends Employee { String language; Developer(String name, String language) { super(name); // Must be the first statement this.language = language; System.out.println("Developer initialized with: " + language); } } public class Main { public static void main(String[] args) { new Developer("Alice", "Java"); } }
Take Your Shot
Predicted Output

Type exactly what you think will be printed in the console.

3. The 'super' Keyword: Constructor Chaining | DevExCode