Question: Assume that class Person has following two private data fields: private String name; private int cpr; and following constructor: public Person(String n, int c) {name

Assume that class Person has following two private data fields: private String name; private int cpr; and following constructor: public Person(String n, int c) {name = n; cpr = c;} Now, we want to write a class called Teacher that inherits the properties of class Person having following two data fields: private String college; private String department; The constructor of class Teacher can be written as follows: public Teacher (String n, int c, String co, String d) name = n; cpr = c; college = co; department=d; } . public Teacher (String n, int c, String co, String d) { super(n, c); college = co; department=d; } public Teacher (String n, int c, String co, String d) { this(n, c); college = co; department=d; } public Teacher (String n, int c, String co, String d) { supern, c); college = co; department=d; D
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
