B.7-TO-B.12 Please use the code below for questions B.7 to B.12. PleaseWrite 2 c
ID: 3720927 • Letter: B
Question
B.7-TO-B.12 Please use the code below for questions B.7 to B.12. PleaseWrite 2 constructors: one has no argument and the other has provide answers to the questions in the empty space following each question. Do not write within the code below.objects): CSC210Examl and CSC210Exam2 B.8-7 Points two. Use each constructor to create 1 object (totally 2 (Hint: Remember to keep track of the number of objects public class CSC210Exan created.) // Static Uariables // Instance Uariables private String exanNane; private double exanMaxPoints; /1 Constructors // Static Methods Instance Methods public class CSC210ExanMainExplanation / Answer
CSC210ExamMain.java
public class CSC210ExamMain {
public static void main(String[] args) {
CSC210Exam CSC210Exam1 = new CSC210Exam();
CSC210Exam CSC210Exam2 = new CSC210Exam("Suresh", 100);
System.out.println("Number of objects: "+CSC210Exam.numberOfExams);
System.out.println("Number of objects: "+CSC210Exam.getNumberOfExams());
}
}
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 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;
}
}
Output:
Number of objects: 2
Number of objects: 2
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.