Write a java program to create an abstract class Student. Inherit UG_Student class and PG_Student class from the Student class. Define constructors and appropriate methods to display details of students. Make necessary assumptions.
JAVA PROGRAM:-
// Abstract class Student
abstract class Student {
private String name;
private int age;
private String studentID;
// Constructor for Student class
public Student(String name, int age, String studentID) {
this.name = name;
this.age = age;
this.studentID = studentID;
}
// Getter methods
public String getName() {
return name;
}
public int getAge() {
return age;
}
public String getStudentID() {
return studentID;
}
// Abstract method to display details
public abstract void displayDetails();
}
// UG_Student class inheriting from Student
class UG_Student extends Student {
private String major;
// Constructor for UG_Student class
public UG_Student(String name, int age, String studentID, String major) {
super(name, age, studentID);
this.major = major;
}
// Getter method for major
public String getMajor() {
return major;
}
// Overriding the abstract method to display details
@Override
public void displayDetails() {
________ _____ _________ _____ __________ _________ ________ ___.
__________ ___ _______ ______ _____ __________ ___ _________ ____ ____ ______ ____.
____ ________ _________ __________ ____ ______ ________ _________ _____.
____ _______ _______ __________ ___ _______ ____ ____.
_____ _________ ____ _______ ___.
____ ________ _________ ____ ______ _______.
____ __________ _________ __________ _________ __________.
________ ______ ________ ________ ________ ____ _____ _________ ______ __________ ___ _______.
___ _____ _____ ________ ________ ____ _________ ________ _________ __________ __________.
________ ____ _________ ________ ________.
___ ______ _________ __________ __________.
_________ ______ __________ _________ ___.
_________ ________ ___ _______ _________ _________ _______ __________.
___ _____ _______ ______ ____ ________ ______ _____.
_________ ________ ____ _____ _______ _____ ____ __________ __________ ___ _____.
________ ______ _________ ________ ____ ______.
__________ ____ ____ _______ ___ _______ _________ ________ ___ ___ _____ __________.
___ _______ ____ ________ ____.
__________ ____ ____ ________ _________ _______ ________.
__________ _________ __________ ______ ___ __________ ______ _______.
_______ _______ ___ ________ __________ ________ ____ ____ ________ ___ _____ _______.
___ ____ ________ _____ ____ ____ _____ ______ __________.
___ _______ ___ ___ __________ ______ ________ ___ _________ ___ __________.
_________ _____ ___ ________ ___ _____ ________ ____ ___ ____ ________ __________.
_____ _______ _________ _______ ________ __________ ____ ____ __________ ______ _________.
_________ ________ _____ _______ ___.
____ ____ ________ __________ _____ _____ ___ _________ ______ __________ ______.
_______ _______ _______ ___ ________ ________ _______ ___.
___ ____ ________ _______ __________ __________ ____ _______ __________ ___ _________ ________.
___ _____ __________ __________ ____ ___ ___ _______ __________ ___ ______ ___.
________ __________ ___ _______ _____ _____ ____ ____ ________ _____ ____.
_______ ______ ____ ___ ____ __________ ________ _____ ______ ________ ____.
____ ___ _______ _______ _____ _______ ______ ____ ____ __________ _______.
_____ _________ __________ ________ __________ ___ _____ _______ ______ ____.
_______ _______ __________ _______ ___ ________ _____ ______ _____ ________.
________ _________ ____ ___ _______ ____ ________ _________ ______ ___ ______.
_________ _________ ___ ________ __________ ______ ________ ___ ___ __________ _______.
______ ____ _________ _______ ____ _______ _____ ___ _____ ________ _______.
___ _________ _______ ________ __________ __________ __________.
________ _______ ____ ___ _______ _____ ________ ___ _________ _______.
_____ _________ ___ ________ _______ _________ ________ _________ _______.
_______ _______ ______ ___ _________ _______ ___ ________ ________ ___ ________.
____ _______ _____ _______ ____ ____.
____ _____ _____ ________ ____ ___ _________ ___ ____ _____ _______.
_____ _________ _________ __________ _______.
______ ____ ____ _____ ___ ______ ______ _____ _______.
________ ____ __________ ______ __________ _______ ________ ___.
____ ________ _________ ______ ______ ______ _____ _________ _____ _______ __________.
______ ______ _____ _____ _______ _________ ______ ___ ____.
_________ __________ _______ __________ _________ ___ _______ ___ ___ _______ ______ ______.
_________ ___ ___ __________ ______ ____ __________ ___ _____ __________ ____ ___.
______ _________ ____ _____ __________.
- Solved Assignments
- Study Notes
- Guess Papers
- Question Papers
✓ Unlock up to 60% of the answer
✓ No payment required