Question: A Java program has a class called Enrolment that stores information about a particular student's enrolment details. The class has a Student object as one
A Java program has a class calledEnrolmentthat stores information about a particular student's enrolment details.
The class has aStudentobject as one of its fields. The program designer has chosen to store the student ID as a field in both theEnrolmentclassandtheStudentclass
This is
Question Answer
a
Bad program design it is an example of code duplication, which should be avoided.
b
Necessary, as both the Enrolment and Student classes need to access this information.
c
Good program design, as having the variable in two different places ensures it will be correct.
d
Bad program design it will cause a syntax error, as you can't declare the same field in two different classes.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
