Question
Student and Department Detail Create a class Department with the following private member variables int did String dname Include appropriate getters and setters method in
Student and Department Detail
Create a class Department with the following private member variables
- int did
- String dname
Include appropriate getters and setters method in Department class.
Create a class Student with the following private member variables
- int sid
- String sname
- Department department
Include appropriate getters and setters method in Student class.
Create a TestMain class which has main method.
In addition to main method, create a method
public static Student createStudent() -All input as shown in the sameple input should be got in this method.Set the values to the Student object and return that object
Note : In main method, invoke the createStudent method and print the details of the object returned by that method.
Sample Input 1:
Enter the Department id:
100
Enter the Department name:
Computerscience
Enter the Student id:
123
Enter the Student name:
sudhaSample Output 1:
Department id:100
Department name:Computerscience
Student id:123
Student name:sudha
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