Consider the following class: 1 public class Student { 2 private int studentNumber; 3 private Student labPartner; 4 private static Student classPres = null; 5 private static int nextStudentNumber = 100; 6 7 public Student () { 8 this.studentNumber = Student.nextStudentNumber; 9 Student.nextStudentNumber ++; 10 this.labPartner = null; 11 } 12 13 public void setLabPartner (Student labPartner) { 14 this.labPartner = labPartner; 15 } 16 17 public static void setClassPres (Student pres) { 18 Student.classPres = pres; 19 } 20 } (a) Write code that is able to construct an array of 1000 student objects and loads them in increasing student number order into that array. The lab partners of these students should all be null. The classPres should also be null.
Consider the following class:
1 public class Student {
2 private int studentNumber;
3 private Student labPartner;
4 private static Student classPres = null;
5 private static int nextStudentNumber = 100;
6
7 public Student () {
8 this.studentNumber = Student.nextStudentNumber;
9 Student.nextStudentNumber ++;
10 this.labPartner = null;
11 }
12
13 public void setLabPartner (Student labPartner) {
14 this.labPartner = labPartner;
15 }
16
17 public static void setClassPres (Student pres) {
18 Student.classPres = pres;
19 }
20 }
(a) Write code that is able to construct an array of 1000 student objects and loads them in increasing
student number order into that array. The lab partners of these students should all be null. The
classPres should also be null.
Step by step
Solved in 2 steps