In a college, Student s1 chooses a set of courses. Student s2 also chooses all the courses chosen by s1 except the second course, in place of which s2 chooses another course. Write a program that defines two classes Student and Admission. Define a copy constructor to create s2 from s1 such that changing the values of instance variables of either s2 or s1 does not affect the other one. The code takes the name of student s2 and the new course chosen by s2 as input.
Student has/should have the following members.
String name and String[] courses to store the name and the courses chosen, respectivelygetName() and getCourses(int) to get the name of the student and the course at a specific index, respectively.setName(String) and setCourses(int, String) to set the name of the student and the course at a specific index, respectively.Admission has method main that does the following.
Student, s1 and s2, are created. s2 is created using s1.s2 and the second course chosen by s2 are updated by taking the input.s1 and s2 and the second course chosen by s1 and s2 are printed.What you have to do:
StudentIn a college, Student `s1` chooses a set of courses. Student `s2` also chooses all the courses chosen by `s1` except the second course, in place of which `s2` chooses another course. Write a program that defines two classes `Student` and `Admission`. Define a copy constructor to create `s2` from `s1` such that changing the values of instance variables of either `s2` or `s1` does not affect the other one. The code takes the name of student `s2` and the new course chosen by `s2` as input. - Class `Student` has/should have the following members. - Private instance variables `String name` and `String[] courses` to store the name and the courses chosen, respectively - Define the required constructor(s) - Accessor methods `getName()` and `getCourses(int)` to get the name of the student and the course at a specific index, respectively. - Mutator methods `setName(String)` and `setCourses(int, String)` to set the name of the student and the course at a specific index, respectively. - Class `Admission` has method `main` that does the following. - Two objects of `Student`, `s1` and `s2`, are created. `s2` is created using `s1`. - The name of Student `s2` and the second course chosen by `s2` are updated by taking the input. - Finally, the names of `s1` and `s2` and the second course chosen by `s1` and `s2` are printed. What you have to do: - Define constructor(s) in class `Student` Complete the Java program to demonstrate the use of abstract classes and interfaces. You have to complete the definition of classes `JuniorRS` and `SeniorRS` to obtain the output as given in the public test cases. - Interface `IResearchScholar` has two methods: `public void teaches(String str)` and `public void studies(String str)`. - Define classes `JuniorRS` and `SeniorRS` such that `JuniorRS` implements `IResearchScholar` and `SeniorRS` extends `JuniorRS`. - Class `InterAbstrTest` extends `SeniorRS`, and has the main method. An object of `JuniorRS` invokes the method `studies`, and an object of `SeniorRS` invokes the methods `studies` and `teaches`. Complete the Java code that uses the concept of inheritance to demonstrate dynamic method dispatching. - Class `Vehicle` has the following members: - Private instance variable `name` - Constructor to initialize `name` - Accessor method for `name` - Method `display` to display the text: `This is a generic vehicle.` Classes `Car` and `Bicycle` should be defined in such a way that any object of `Car` or `Bicycle` can be assigned to a reference variable of type `Vehicle`. See the main method to understand the context. - For `Car`, the method `display` should print: `This is a car named <name>.` - For `Bicycle`, the method `display` should print: `This is a bicycle named <name>.` In the main method of the `DispatchExample` class, an array of `Vehicle` objects of size 3 is created. - The first element is a generic vehicle (with an empty string for its name). - The second and third elements are a `Car` and a `Bicycle`, respectively, with the vehicle's name taken as input. - It iterates over the array and calls the `display` method for each vehicle. What you have to do: - Define an accessor method for `name` and method `display` inside class `Vehicle` - Define classes `Car` and `Bicycle`