Question
USE JAVA LANGUAGE USE JAVA LANGUAGE Please write code that meets the following requirements: Create an abstract class called Student Has private attributes name (String),
USE JAVA LANGUAGE
USE JAVA LANGUAGE
Please write code that meets the following requirements:
Create an abstract class called Student
Has private attributes name (String), mayLiveOnCampus (boolean)
Create a constructor that requires both parameters
Has getters for name and mayLiveOnCampus (but not setters)
Has a toString () method implemented (use NetBeans for this)
Has a public abstract boolean method called hasPriorityEnrollment ()
Create a concrete class called MatriculatedStudent
Inherits from Student
Has a private attribute for Student ID named studentId (string)
Implements only one constructor that requires BOTH name and student
ID, and calls the superclass constructor with the name plus true for
mayLiveOnCampus
Implements hasPriorityEnrollment (), returns true
Create a concrete class called NonMatriculatedStudent
Inherits from Student
Has a private attribute for Social Security Number named ssn (string)
Implements only one constructor that requires BOTH name and SSN, and
calls the superclass constructor with the name plus false for
mayLiveOnCampus
Implements hasPriorityEnrollment (), returns false
Create a class Main which has a main method like this:
public static void main(String[] args) { Student s1 = new MatriculatedStudent("Deena", "SB158320"); Student s2 = new NonMatriculatedStudent("Edward",
"123-45-6789" );
System.out.println(s1); System.out.println(s2);
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started