Explanation of Solution
a.
Given line:
Person p1 = new Student ();
Explanation:
The “Person” and “Student” are two classes. The class “Student” is the derived class and “Person” is the base class...
Explanation of Solution
b.
Given line:
Person p2 = new Undergraduate ();
Explanation:
The “Person” and “Undergraduate” are two classes...
Explanation of Solution
c.
Given line:
Student s1 = new Person ();
Explanation:
The “Person” and “Student” are two classes. The class “Student” is the derived class and “Person” is the base class...
Explanation of Solution
d.
Given line:
Student s2 = new Undergraduate ();
Explanation:
The “Undergraduate” and “Student” are two classes. The class “Undergraduate” is extend from the “Student” class...
Explanation of Solution
e.
Given line:
Undergraduate ug1 = new Person ();
Explanation:
The “Undergraduate” and “Person” are two classes. The class “Undergraduate” is extend from the “Student...
Explanation of Solution
f.
Given line:
Undergraduate ug2 = new Student ();
Explanation:
The “Undergraduate” and “Person” are two classes. The class “Undergraduate” is extend from the “Student...
g.
“Object” class:
All classes in Java inherit from the “Object” class.
- • Directly and indirectly all classes are inherited from the “Object”class.
- • Some of the basic methods of the “Object” class are listed below:
- ○ clone()
- ○ toString()
- ○ equals()
The above methods are automatically created in java when a class is created.
h.
“Object” class:
All classes in Java inherit from the “Object” class.
- • Directly and indirectly all classes are inherited from the “Object”class.
- • Some of the basic methods of the “Object” class are listed below:
- ○ clone()
- ○ toString()
- ○ equals()
The above methods are automatically created in java when a class is created.
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Java: Intro. to Prob. Solv... (Looseleaf)
- Answer the following questions about the given statement:{c : Course |∃co : Customer • (co,c) ∈Books ∧co.classcredit >2}•What does this statement mean?•Is this statement a set or a predicate?•What does the statement evaluate to based on the current system state? Examples for reference:•∃g : Owner • g.name = gymowner ∧g.email = test-There exists an owner with the name gymowner and email test-predicate-false•{c : Course |∃co : Customer • (co,c) ∈Books}-Set of all Courses which are booked by a customer-set-{Boxing,WeightLifting,Yoga1,Wrestling}•{t : Trainer |#{c : Course |(t,c) ∈Teaches}>1}-Set of all Trainers who teach more than 1 class.-set-{Trainer 2}arrow_forwardConsider the following code snippet. 1. /* 2. * The Student class models a student with a name, age 3. * and a faculty in which is currently enrolled in. 4. */ 5. public class Student 6. { 7. // private instance variable, not accessible from outside this class 8. private String firstName; 9. private String lastName; 10. private int birthYear; 11. private String faculty; 12. 13. // The constructor with the. correspondent parameters. 14. public Student(String first, String last, int birthYear, String faculty) 15. { 16. this.firstName= first; 17. this.lastName = last; 18. this.birthYear = birthYear; 19. this.faculty = faculty; 20. } 21. } 1. Implement an accessor method that returns the age of the student given as parameter the current year. 2. Implement a new method called printDetails, taking the currentYear as a parameter, that prints the full name, age and faculty of the student in the following way: Full name: Donald Duck Age: 24 years Faculty:…arrow_forwardWrite a program that does the following: 1-Define two classes Teacher and Department. Each Teacher has a department object as follow: [3 points] class Department{ int dno; char *name; //add data member to count number of departments automatically public: //add required methods here //define print function that prints all details of department. Note that print function is NOT function member of class Department }; class Teacher{ const int SSN; char *name; Department d; public: //add all required methods //define print function that prints all details of Teacher. Note that print function is NOT function member of class Teacher } 2-inside main do the following: a) create array of 5 Teachers. add all required details for each object inside a loop.(do NOT use cin>>) b)use print function for department and use print function for student. c)define and use a function FindTeachers that takes the array of Teachers and name of department. Then the function returns a list of all Teachers…arrow_forward
- Answer the following questions about the given statement:∃c : Course • c.private ∧∃co : Customer • (co,c) ∈Books ∧c.name = Customer 4•What does this statement mean?•Is this statement a set or a predicate?•What does the statement evaluate to based on the current system state? Examples for reference:•∃g : Owner • g.name = gymowner ∧g.email = test-There exists an owner with the name gymowner and email test-predicate-false•{c : Course |∃co : Customer • (co,c) ∈Books}-Set of all Courses which are booked by a customer-set-{Boxing,WeightLifting,Yoga1,Wrestling}•{t : Trainer |#{c : Course |(t,c) ∈Teaches}>1}-Set of all Trainers who teach more than 1 class.-set-{Trainer 2}arrow_forwardAnswer the following questions about the given statement:∀c : Courses • ∃co : Customer • (co,c) ∈Books•What does this statement mean?•Is this statement a set or a predicate?•What does the statement evaluate to based on the current system state? Examples for reference:•∃g : Owner • g.name = gymowner ∧g.email = test-There exists an owner with the name gymowner and email test-predicate-false•{c : Course |∃co : Customer • (co,c) ∈Books}-Set of all Courses which are booked by a customer-set-{Boxing,WeightLifting,Yoga1,Wrestling}•{t : Trainer |#{c : Course |(t,c) ∈Teaches}>1}-Set of all Trainers who teach more than 1 class.-set-{Trainer 2}arrow_forwardUsing classes and arrays, the team will develop a set of functions for an onlineshopping system. The system is represented by the following structure:1- Class Item having the following private attributes: (ID, name, quantity, price) andthe following public methods:- Constructors (default, parameterized, and copy)- Setters & Getters- Operator overloading for the ==, +=,-=, >> and << operators Note that the ID member variable is not entered or read from the user. It isautomatically set by the class as a serial ID starting with the first item of ID 1 andincrementing with every new object.2- Class Seller having the following private attributes: (name, email, items,maxItems),where items is a dynamic array of objects of type Item with the size maxItems. Theclass has the following public methods:- Constructor (parameterized)- Operator overloading for the insertion << operators- Add An Item.- This will take an Item object as a parameter:- If the item already exists in the…arrow_forward
- Give an example of a class and an example of an object. Describe what a class is, what an object is, and how they are related. Use your examples to illustrate the descriptions. Your Discussion should be at least 250 words in length, but not more than 750 words. Once you’ve completed your initial post, be sure to respond to the posts of at least 3 of your classmates.arrow_forwardWhich of the following, can be done, with the help of the this reference?arrow_forwardUsing classes and arrays, the team will develop a set of functions for an online shopping system. The system is represented by the following structure: 1- Class Item having the following private attributes: (ID, name, quantity, price) and the following public methods:- Constructors (default, parameterized, and copy)- Setters & Getters- Operator overloading for the ==, +=,-=, >> and << operatorsNote that the ID member variable is not entered or read from the user. It is automatically set by the class as a serial ID starting with the first item of ID 1 and incrementing with every new object.2- Class Seller having the following private attributes: (name, email, items,maxItems), where items is a dynamic array of objects of type Item with the size maxItems. The class has the following public methods:- Constructor (parameterized)- Operator overloading for the insertion << operators- Add An Item.- This will take an Item object as a parameter:- If the item already exists…arrow_forward
- I need help with this question, which should be completed in C# programming language.(Non-other) Complete the Person (base), Student (derived), Faculty (derived), Admin (derived), Staff (derived) Classes Use the following properties: 1- Person properties - firstName, lastName, email (type string), Person method - PersonWrite 2- Student properties - studentID (private string), use a getter and setter, define 2 constructors Student method - StudentWrite 3- Faculty properties - facultyID (private string), use a getter and setter, define 2 constructors Faculty method - FacultyWrite 4- Admin properties - adminID (private string), use a getter and setter, define 2 constructors Admin method - AdminWrite 5- Staff properties - staffID (private string), use a getter and setter, define 2 constructors Staff method - StaffWrite Initialize each of the classes, and print out the contents of each class to show inheritance. Create a Class Diagram for your program using VS Class Diagram/Designer…arrow_forwardAnswer the following questions about the given statement:∀t : Trainers • ∃c : Course • (t,c) ∈Teaches ∧c.time = 2•What does this statement mean?•Is this statement a set or a predicate?•What does the statement evaluate to based on the current system state? Examples for reference:•∃g : Owner • g.name = gymowner ∧g.email = test-There exists an owner with the name gymowner and email test-predicate-false•{c : Course |∃co : Customer • (co,c) ∈Books}-Set of all Courses which are booked by a customer-set-{Boxing,WeightLifting,Yoga1,Wrestling}•{t : Trainer |#{c : Course |(t,c) ∈Teaches}>1}-Set of all Trainers who teach more than 1 class.-set-{Trainer 2}arrow_forwardAnswer the following questions about the given statement:∃c : Course • c.type = Boxing ∧∃co : Customer • (co,c) ∈Books ∧∃t : Trainer •(t,c) ∈Teaches ∧t.credit >1•What does this statement mean?•Is this statement a set or a predicate?•What does the statement evaluate to based on the current system state? Examples for reference:•∃g : Owner • g.name = gymowner ∧g.email = test-There exists an owner with the name gymowner and email test-predicate-false•{c : Course |∃co : Customer • (co,c) ∈Books}-Set of all Courses which are booked by a customer-set-{Boxing,WeightLifting,Yoga1,Wrestling}•{t : Trainer |#{c : Course |(t,c) ∈Teaches}>1}-Set of all Trainers who teach more than 1 class.-set-{Trainer 2}arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,