public class CSC210Exam // Static Uariables // Instance Uariables private String
ID: 3721590 • Letter: P
Question
public class CSC210Exam // Static Uariables // Instance Uariables private String examNane; private double examMaxPoints; // Constructors // Static Methods // Instance Methods public class CSC219ExanMain public static void main(String[] args) t Why data fields should be private? Write a setter method and a getter method for the data field examMaxPoints. If you move the main method into the class CSC210Exam, should we expect errors? Explain why. Write statement(s) to update examName of the existing object named CSC210Exam3.Explanation / Answer
CSC210Exam.java
public class CSC210Exam{
public static int numberOfExams = 0;
public static final int MAX = 100;
private String examName;
private double examMaxPoints;
public CSC210Exam(){
numberOfExams++;
}
public CSC210Exam(String name, double p){
examMaxPoints=p;
examName=name;
numberOfExams++;
}
public static int getNumberOfExams() {
return numberOfExams;
}
public static int getMax() {
return MAX;
}
public static void setNumberOfExams(int numberOfExams) {
CSC210Exam.numberOfExams = numberOfExams;
}
public String getExamName() {
return examName;
}
public void setExamName(String examName) {
this.examName = examName;
}
public double getExamMaxPoints() {
return examMaxPoints;
}
public void setExamMaxPoints(double examMaxPoints) {
this.examMaxPoints = examMaxPoints;
}
}
There will be no errors if we move main method to CSC210Exam class.
CSC210Exam3.setExamName("Computer Science");
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.