InstructionsPerform the following items. Mobile users may write their answers on a clean sheet of paper. (8 items x 5 points)
SOLUTION TO THE ABOVE QUESTION
SOLUTION CODE
class Exam{
private String message;
private double price;
private boolean status;
// part i
public Exam(){
this.message="Good luck";
}
//part ii
public Exam(String period, String level)
{
//empty constructor
}
//part iii
public double getprice()
{
return price;
}
//part iv
public boolean isFinished()
{
return status;
}
}
//part v
//A derived class midterm derived from Exam
class midterm extends Exam
{
public midterm()
{
//part vii
// call the parent class constructor
super();
System.out.println("Exam has started.");
}
}
//part vi
//A class Essay derived from midterm class
class Essay extends midterm
{
//methods and fields
}
public class Main {
public static void main(String[] args) {
//
}
}
Comments
Leave a comment