Object Oriented Programming With Java Lab Exercises And Solutions Pdf Apr 2026
public Student(String name, int studentId) { this.name = name; this.studentId = studentId; this.grades = new double[10]; this.gradeCount = 0; }
public double calculateAverage() { double sum = 0; for (int i = 0; i < gradeCount; i++) { sum += grades[i]; } return gradeCount > 0 ? sum / gradeCount : 0; } public Student(String name, int studentId) { this
public void displayInfo() { System.out.println("Student: " + name + " (ID: " + studentId + ")"); System.out.println("Average Grade: " + calculateAverage()); } } public Student(String name