Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a . Discuss the visibility properties of every instance field defined in Student class, following the below format: Q 4 a Answer Instance field: Method

a. Discuss the visibility properties of every instance field defined in Student class,
following the below format:
Q4a Answer
Instance field:
Method or methods where the field is published:
Is the field safely published?
Possible visibility problems for this field:
public class Student {
public String id;
private String name;
private volatile boolean active;
private ArrayList exams;
public Student(String id, String name){
this.id = id;
this.name = name;
this.active = false;
this.exams = new ArrayList();
}
public synchronized String getName(){
return this.name;
}
public synchronized void register(Module module){
module.addStudent(this.id);
this.active = true;
}
public synchronized void addExam(Exam exam){
this.exams.add(exam);
}
public synchronized ArrayList getTranscript(){
return new ArrayList(this.exams);
}
public void printTranscript(){
if (! this.active){
System.out.println("(currently inactive)");
}
synchronized(this){
System.out.println("Student "+ this.name);
for (Exam e: this.exams){
System.out.println(e.toString());
}
}
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions