Using Java, I want he right answer!!! Question 1: (practice to write the code fo
ID: 3852244 • Letter: U
Question
Using Java, I want he right answer!!!
Question 1: (practice to write the code for no-argument constructor and parameter constructor) This question talks about the class named TheClass that hold 4 private data members as below:
public class TheClass {
//data members
private String subject;
private String classSession;
private String roomNumber;
private String instructorID;
//no-argument constructor ……………..
//parameter constructor ……………. }
a. Write a parameter no-argument constructor for TheClass.
b. Write a parameter constructor that accepta 4 String parameters to initialize values to the field subject, classSession, roomNumber and instructorID
Explanation / Answer
JAVA CLASS:
public class TheClass {
//data members
private String subject;
private String classSession;
private String roomNumber;
private String instructorID;
//no-argument constructor ……………..
public TheClass() {
}
//parameter constructor …………….
public TheClass(String subject, String classSession, String roomNumber, String instructorID) {
this.subject = subject;
this.classSession = classSession;
this.roomNumber = roomNumber;
this.instructorID = instructorID;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.