Question: JAVA Add a method to the lecturer object that changes the students marks. This method should be defined to take a student object and a

JAVA

Add a method to the lecturer object that changes the students marks. This method should be defined to take a student object and a number as arguments.

Write a program that creates one student and lecturer object. The program should invoke the lecturer objects method to change the students marks. The program should also display the details of the student object, including the students new marks.

Person.java

public class Person {

private String ID;

private String name;

private String gender;

public Person(String ID, String name, String gender) {

this.ID = ID;

this.name = name;

this.gender = gender;

}

public String getID() {

return ID;

}

public void setID(String iD) {

ID = iD;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getGender() {

return gender;

}

public void setGender(String gender) {

this.gender = gender;

}

@Override

public String toString() {

return "Person [ID=" + ID + ", name=" + name + ", gender=" + gender + ", getID()=" + getID() + ", getName()="

+ getName() + ", getGender()=" + getGender() + "]";

}

}

Student.java

public class Student extends Person{

private int marks;

public Student(String ID, String name, String gender, int marks) {

super(ID, name, gender);

this.marks = marks;

}

public int getMarks() {

return marks;

}

public void setMarks(int marks) {

this.marks = marks;

}

}

Lecturer.java

public class Lecturer extends Person{

public Lecturer(String ID, String name, String gender){

super(ID, name, gender);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!