...
/Solution Review: Implement the Parametrized Constructor
Solution Review: Implement the Parametrized Constructor
This review provides a detailed analysis to solve the 'Implement the Parametrized Constructor' challenge.
We'll cover the following...
Solution
Press + to interact
// Base Classclass Laptop {// Private Data Membersprivate String name;public Laptop() { // Default Constructorname = "";}public Laptop(String name) { // Default Constructorthis.name = name;}// Getter Functionpublic String getName() {return name;}}// Derived Classclass Dell extends Laptop {public Dell() { // Default Constructor}public Dell(String name) { // Parametrized Constructorsuper(name);}public String getDetails() {return getName();}public static void main(String args[]) {Dell dell = new Dell("Dell Inspiron");System.out.println(dell.getDetails());}}