Students, please be sure to log in. This site does not use cookies and cannot store work submitted when not signed in.

Unit 9 Problems

Employee

Complete the constructor for the Employee class which is a child class of the Personclass shown below. If name is private to Person, how can a child class set it? To call the constructor of a superclass, you use the use super();
The Employee class also has a static int variable called nextId. This variable should increment each time an Employee record is created. In addition, each Employee should have an instance variable to track its assigned id. 

public class Person{
   private String name;

   public Person(String theName){
      this.name = theName;
   }

   public String getName(){
      return name;
   }
}

Super Class Constructor call:

public class A{
   private int data;
   public A(int val){
      this.data = val;
   }
}

public class B extends A{
   public B(int val){
      //call the super constructor to set the data value by passing parameter to constructor
      super(val); 
   }
}
Type your solution        
Skills Practiced:
3.B
4.A
4.B
1.C
Copyright © StudyCS 2024 All rights reserved.