0% found this document useful (0 votes)
3 views3 pages

Assignment Five Java

The document contains Java code defining an abstract class 'Department' and a subclass 'Faculty' that extends it. The 'Faculty' class includes methods to display faculty details and department name. A main class creates an instance of 'Faculty' and displays its details, demonstrating the use of inheritance and abstraction in Java programming.

Uploaded by

Subham Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Assignment Five Java

The document contains Java code defining an abstract class 'Department' and a subclass 'Faculty' that extends it. The 'Faculty' class includes methods to display faculty details and department name. A main class creates an instance of 'Faculty' and displays its details, demonstrating the use of inheritance and abstraction in Java programming.

Uploaded by

Subham Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Registration Number: 12206671 Course Code:CAP680

Roll No: B65 Section: D2214 Group- 2

Sandbox Link:
https://codehs.com/sandbox/subhamguptta/new-sandbox-program-1

Code:
// Abstract Class Department

abstract class Department {

String dept_name;

public Department(String dept_name) {

this.dept_name = dept_name;

public abstract void display_department_name();

// Faculty Class extending from Department

class Faculty extends Department {

String faculty_name;

int faculty_id;

String[] courses;

public Faculty(String faculty_name, int faculty_id, String dept_name, String[] courses) {

super(dept_name);

this.faculty_name = faculty_name;

this.faculty_id = faculty_id;

this.courses = courses;

Page 1 of 5
Registration Number: 12206671 Course Code:CAP680

Roll No: B65 Section: D2214 Group- 2

public void display_department_name() {

System.out.println("Department: " + dept_name);

public void display_faculty_details() {

System.out.println("Faculty Name: " + faculty_name);

System.out.println("Faculty Id: " + faculty_id);

display_department_name();

System.out.println("Courses: " + String.join(", ", courses));

// Main class

public class Main {

public static void main(String[] args) {

// Creating an instance of Faculty class

Faculty f = new Faculty("Kumar", 12345, "SCA", new String[]{"CAP615", "CAP680", "JAVA solution"});

// Displaying Faculty details

f.display_faculty_details();

Screen Shot of Sandbox with code:

Page 2 of 5
Registration Number: 12206671 Course Code:CAP680

Roll No: B65 Section: D2214 Group- 2

Page 3 of 5

You might also like