Question
Please answer all the questions
2. Design two programs named BaseClass and SubClass. In BaseClass, define a variable xVar (type: char, value: 65), and a method myPrint to print xVar. SubClass is a subclass of BaseClass. In SubClass, define a variable yVar (type: int, value: 16) and another variable strVar (type: String, value: java program!). There is also a method myPrint to print the value of yVar and strVar in SubClass, as well as an additional method printAll, in which invoking myPrint method both from the base class and sub class. Write a test program. In the main method, declare an instance of SubClass named bObj. Then use the object to call method printAll to output all the properties of that object. 3. Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, unior, or senio. Define the status as a constant. An employee has an office, salary, and date hired. Define a class named MyDate that contains the fields year, month, and day. A faculty member has office hours and a rank. A staff member has a title. Override the toString method in each class to display the class name and the persons name Draw the UML diagram for the classes. Implement the classes. Write a test program that creates a Person, Student, Employee, Faculty, and Staff, and invokes their toString) methods. e th od 4. Write a Java application which contains a class called ArrayMethods. The ArrayMethods class contains methods with the following headers: public int duplicate(char[ arrayl, char[] array2) This method copies each character from array array1 into the same location of array array2. array2 must have already been instantiated and be of the same or greater length as arrayl. The method returns the number of elements copied. public boolean same (char[ array1, char] array2) This method examines arrays array1 and array2 character by character and retums false if a character in array1 is different than a character at the corresponding location in array2 or if the arrays are of different length. The method returns true if every character of array1 is the same as the corresponding character in array2. These are the only methods in the ArrayMethods clas:s.
media%2F50c%2F50cd50d4-bd98-407c-8bd6-1b
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1 -| s) Given 2n baseelos, define a variable xvar of char typ ard ts value s 16 nt type and 2n . Subclass , define va~aable yvar Value and define anether variable stvar at shng type andThe vlr java pogem Source code Bose class java Pubbe clos Basecloss void myPnt) System out. printin (this xvar); Sub class java Public class Sbclassextends Base class yvay6 ve.id myPwint C void myPrint syatem. out printin(this yva ) system aut printin (this styVar)2 Drivey class javo Poblic Etass Driverclass Puble statie void main (Sting t J a7) Sobclass bobj nes sot class( ) Dedigning a

I hope you understand this. I tried my best. If you have any doubts regarding this please mention in comments. I promise you that I will give reply. Thank You..!

Add a comment
Know the answer?
Add Answer to:
Please answer all the questions 2. Design two programs named BaseClass and SubClass. In BaseClass, define...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • a c++ program (The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person...

    a c++ program (The Person, Student, Employee, Faculty, and Staff classes) Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, and date hired. Use the MyDate classto create an object for date hired. A faculty...

  • Java Programming Design a class named Person and its two subclasses named Student and Employee. A...

    Java Programming Design a class named Person and its two subclasses named Student and Employee. A person has a name, address, phone number, and email address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, date hired. Define a class named MyDate that contains the fields year, month, and day. Override the toString method in each class to display the class name and the person's name....

  • Concepts Tested in this Program: Class Design Constructors Objects Inheritance Program:   Design a class named Person...

    Concepts Tested in this Program: Class Design Constructors Objects Inheritance Program:   Design a class named Person and its two subclasses, Student and Employee. Make Faculty and Staff subclasses of Employee. A Person object has a name, address, phone number, and email address (all Strings). A Student Object has a class status (freshman, sophomore, junior, or senior). Define the status as a final String variable. An Employee Object has an office number, salary (both ints ), and a date hired. Use...

  • Part I: (The Myate class) Design a class named MyDate. The class contains: • The data...

    Part I: (The Myate class) Design a class named MyDate. The class contains: • The data fields year, month, and day that represent a date. Month is 0-based, i.e., 0 is for January. • A no-arg constructor that creates a MyDate object for the current date. • A constructor that constructs a MyDate object with a specified elapsed time since midnight, January 1, 1970, in milliseconds. • A constructor hat constructs a MyDate object with the specified year, month, and...

  • Design a class named Person and its two derived classes named Student and Employee. MakeFaculty and Staff derived classes of Employee

    In Java(The Person, Student, Employee, Faculty, and Staff classes)Design a class named Person and its two derived classes named Student and Employee. MakeFaculty and Staff derived classes of Employee. A person has a name, address, phone number, and e-mail address. A student has a class status (freshman, sophomore, junior, or senior). An employee has an office, salary, and date hired. Define a class namedMyDate that contains the fields year, month, and day. A faculty member has office hours and a rank....

  • Implement an abstract class named Person and two subclasses named Student and Staff in Java. A person has a name, address, phone number and e-mail address. A student has a credit hour status (freshman...

    Implement an abstract class named Person and two subclasses named Student and Staff in Java. A person has a name, address, phone number and e-mail address. A student has a credit hour status (freshman, sophomore, junior, or senior). Define the possible status values using an enum. Staff has an office, salaray, and date-hired. Implement the above classes in Java. Provide Constructors for classes to initialize private variables. Getters and setters should only be provided if needed. Override the toString() method...

  • Please provide the code for the last part(client side program). yes i have all the class...

    Please provide the code for the last part(client side program). yes i have all the class implementations. ``` person.h #ifndef PERSON_H #define PERSON_H #include <string> using namespace std; class person { public: person(); string getname() const; string getadd() const; string getemail() const; string getphno() const; string toString() const; private: string name; string add; string email; string phno; }; ```person.cpp #include "person.h" person::person() { name = "XYZ"; add="IIT "; email="%%%%"; phno="!!!!!"; } string person::getname() const { return name; } string person::getadd()...

  • Please give the code without errors Define a class named Doctor whose objects are records for...

    Please give the code without errors Define a class named Doctor whose objects are records for a clinic's doctors. Derive this class from the class Person given in Listing 8.1. It's also posted here in this module. A Doctor record has the doctor's name-defined in the class Person,-a specialty as a String (Pediatrician, Obstetrician, General Practitioner, and so on--these are just examples. The type is String.), and an office-visit fee (use the type double). Give your class a constructor and...

  • Hello! This is C++. Q3. Write a program Define a Super class named Point containing: An...

    Hello! This is C++. Q3. Write a program Define a Super class named Point containing: An instance variable named x of type int. An instance variable named y of type int. Declare a method named toString() Returns a string representation of the point. Constructor that accepts values of all data members as arguments. Define a Sub class named Circle. A Circle object stores a radius (double) and inherit the (x, y) coordinates of its center from its super class Point....

  • please write in Java and include the two classes Design a class named Fan (Fan.java) to...

    please write in Java and include the two classes Design a class named Fan (Fan.java) to represent a fan. The class contains: An int field named speed that specifies the speed of the fan. A boolean field named fanStatus that specifies whether the fan is on (default false). A double field named radius that specifies the radius of the fan (default 5). A string field named color that specifies the color of the fan (default blue). A no-arg (default) constructor...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT