Consider the following class hierarchy: class Animal { ... } class Mammal extends Animal { ... } class Cat extends Mammal { ... } Write a generic method printArray that takes an array of any type and prints each element of the array. If the element is an instance of Animal or its subclass, the method should call the toString method of the object to print its details. Otherwise, the method should simply print the element. Your method should have the following signature: public static void printArray(T[] array)
Q: What exactly is meant by the phrase "computer graphics"? What are the most significant uses for…
A: Computer Graphics refers to creating, manipulating, and representing images and visual information…
Q: In the context of server operating systems, what features does Windows Server 2008 R2 bring to the…
A: In the context of server operating systems, what features does Windows Server 2008 R2 bring to the…
Q: Computer Science [1 for 2 correct sketches ] [0 for 1 correct sketch ] sider the function…
A: The analysis of a function's domain and range is an essential part of understanding its behavior and…
Q: What exactly is meant by the phrase "real-time system" for people who aren't acquainted with it?
A: A real-time system is a category of computer systems created to react to events or inputs in a…
Q: Discuss the development of the information system, concentrating on the individuals and events that…
A: The development of information systems has been a gradual process that has taken place over many…
Q: If you were running a company targeted by various malicious software attacks, then what type of…
A: Here is your solution :
Q: Why do some analysts choose empirical data analysis (EDA) over hypothesis testing when it comes to…
A: Empirical Data Analysis (EDA) ) and Hypothesis Testing are two normal techniques utilized in data…
Q: Which three things are the primary priorities of a programme?
A: A program is a collection of related projects, coordinated in a way that provides benefits beyond…
Q: OOP requires encapsulation. Encapsulated properties are opaque to programmers. He/she can only…
A: Encapsulation is one of the four necessary main outlook of Object-Oriented education (OOP) and is…
Q: 2. Suppose the diagram shows the current heap status, ie. PO and P1 are in the memory, the shaded…
A: According to the Bartleby guideline, we are supposed to answer only one question at a time. Kindly…
Q: Solve the following codes below and discuss how array, stack, and queues are used in each problem.…
A: Solved three programming problems using arrays, stacks, and queues. Below are the python codes for…
Q: On the cmsy255 server, write a bash shell script called usrinfo that displays information about a…
A: SOLUTION- I have solved this problem in bash code with comments and screenshot for easy…
Q: What are some of the best practises that you should be aware of when it comes to the maintenance of…
A: To make sure the optimal presentation of firewalls, it is essential to take out regular conservation…
Q: Please provide an example of how the use of computers might be advantageous. What do you think about…
A: Numerous advantages and benefits have resulted from the use of computers in many different fields.…
Q: Is it essential to have a Master file given that it houses data for the long term?
A: Individuals may have questions related to the importance of having a Master file for long-term data…
Q: In the ER-Model, what are the guidelines for determining how to identify and build relationships…
A: The Entity-Relationship (ER) Model is a high-level data model used to stand for the arrangement of a…
Q: Is the development of networks comprised of four distinct stages?
A: Network development refers to the process of creating, growing, and managing a network of…
Q: What opportunities exist for us as individuals, as a community, and as a family to capitalise on the…
A: In the many civilizations across the globe, contemporary scientific techniques have paved the way…
Q: In our newly created register file, we are only able to write one piece of data at a time. What…
A: A register file is a type of digital electronic memory that consists of a collection of individual…
Q: To better understand the layout of a real-time system, you should draw a detailed diagram to…
A: Real-Time Operating System (RTOS): "Real-Time" and "Operating System." An operating system (OS) is…
Q: To a fellow student, what sort of storage medium would you recommend?
A: A storage media is a physical device in a computer that receives, stores, and retrieves electronic…
Q: Find out how people react when they have issues with computers and mobile applications. Investigate…
A: A company-wide network may link computers that are in different buildings or even different cities.…
Q: Cloud Function as a Service"
A: The types of cloud computing services are Software as a Service Platform as a Service…
Q: How is it possible for a computer to multitask when there is only one machine available? A real-life…
A: What is computer: A computer is an electronic device that can perform various operations based on…
Q: Is there a range of cloud computing services that a user may use that caters to their specific…
A: Cloud Computing can be defined as practice of using the network of remote servers hosted on internet…
Q: Address Validation Imagine you get a data set from a client that contains addresses from 150…
A: Address validation is an essential step in data management that ensures that the data entered in the…
Q: Several reactions are carried out in a closed vessel. The following data are taken for the…
A: Given, Create a proper plot for the experimental data that shows how the concentration of Compound…
Q: In its current iteration, does this backing representation, which is just a two-dimensional singly…
A: The advantages and disadvantages of using a two-dimensional singly linked list as a backing…
Q: There are three methods of data mining that are most often used.
A: Data mining: Gaining information from enormous data stores is called "data mining," and the phrase…
Q: As a consequence of technological advancements such as the internet, are we seeing a more peaceful…
A: It is the Internet that is the most important technological advancement of the information age, just…
Q: Create a list that includes at least five advantages of using cascading style sheets (CSS).
A: Cascading Style Sheets (CSS) is a fundamental technology used in web development for designing the…
Q: These days, an increasing number of businesses are making use of something called "big data." What…
A: Large and complicated datasets that can't be analyzed using conventional data processing techniques…
Q: How deeply should end users be engaged in the process of selecting the database management system…
A: End users ought to be taken part in the process of selecting the database management system (DBMS)…
Q: Which computationally dependent career involves ensuring an organization’s network and the computers…
A: Below are roles of 1) Network and computer systems administrator: Network and computer systems…
Q: Why is it that understanding scalability in the cloud is so difficult? Is there a model that can…
A: Understanding scalability in the cloud is difficult because it involves complex and dynamic…
Q: Find the solution to the recurrence relation an=2nan-1 with the initial condition ao = 3 using an…
A: an= 2nan-1 with the initial condition a0 = 3 he given following procedure. = an=2nan-1…
Q: One of the ways in which a network might be infiltrated and an intrusion can take place is if…
A: VLAN hopping is a network attack where an attacker manipulates the VLAN tagging process to gain…
Q: Name and explain how to get a primitive root modulo 20143 other than 5.
A: Primitive roots are important elements in modular arithmetic. They play a crucial role in various…
Q: How does the organisation of data change between a solid-state drive and a magnetic disc? What are…
A: Data storage technology has come a long way since the early days of computing, and today we have two…
Q: What are the five computer graphics apps that are used the most frequently?
A: Computer graphics applications are a vital part of modern computing, enabling users to create,…
Q: In what ways did the existence of resident monitors contribute to the enhancement of computer…
A: Here is your solution :
Q: Could you perhaps explain what exactly is meant by the term "cloud scalability"? In the context of…
A: The term "cloud scalability" describes a system's or service's capacity to effectively manage…
Q: It would be helpful if you could provide a short explanation of each component of a typical…
A: An operating system (OS) kernel is the core component of an operating system that manages system…
Q: Conventional networks have a greater capacity for available bandwidth than wireless networks do.
A: In the world of computer networking, both wired and wireless networks are essential means of…
Q: Determine the maximum number of physical controllers and displays that can be located. a) Make a…
A: In the modern world, a plethora of physical controllers and displays are available to cater to…
Q: Is RAID a practical replacement for other backup methods? Do you agree or disagree? Why does this…
A: A RAID ( Redundant array of independent disks) is a way of storing the same data in different places…
Q: Focus on dictionary methods, use of functions, and good programming style For this assignment, you…
A: Start. Define a dictionary named "glossary" with pre-defined key-value pairs. Define a function…
Q: Create a function that, given two lists of integer values as input, determines whether or not the…
A: In programming, often we need to compare two lists of integers and check whether they contain the…
Q: How will the information be moved from the form to the website's database?
A: Answer is given below
Q: how to build a bookstore database with Entities for Tables Book Authors Bookstore Members…
A: Building a bookstore database involves identifying the entities and their attributes, creating…
Consider the following class hierarchy:
class Animal { ... }
class Mammal extends Animal { ... }
class Cat extends Mammal { ... }
Write a generic method printArray that takes an array of any type and prints each element of the array. If the element is an instance of Animal or its subclass, the method should call the toString method of the object to print its details. Otherwise, the method should simply print the element.
Your method should have the following signature:
public static <T> void printArray(T[] array)
Step by step
Solved in 5 steps with 1 images
- Implement the following tasks by using concepts of object-oriented programming (Java). i. Create a generic class with a type parameter that simulates drawing an item at random out of a box. This class could be used for simulating a random drawing. For example, the box might contain Strings representing names written on a slip of paper, or the box might contain Integers representing a random drawing for a lottery based on numeric lottery picks. Create an add method that allows the user of the class to add an object of the specified type along with an isEmpty method that determines whether or not the box is empty. Finally, your class should have a drawItem method that randomly selects an object from the box and returns it. If the user attempts to drawn an item out of an empty box, return null. Write a main method that tests your class.ii. The following is a short snippet of code that simulates rolling a 6-sided dice 100 times. There is an equal chance of rolling any digit from 1 to…Write a generic class Students.java which has a constructor that takes three parameters – id, name, and type. Type will represent if the student is ‘remote’ or ‘in-person’. A toString() method in this class will display these details for any student. A generic method score() will be part of this class and it will be implemented by inherited classes. Write accessors and mutators for all data points. Write two classes RemoteStudents.java and InPersonStudents.java that inherits from Student class. Show the use of constructor from parent class (mind you, RemoteStudents have one additional parameter – discussion). Implement the abstract method score() of the parent class to calculate the weighted score for both types of students. Write a driver class JavaProgramming.java which has the main method. Create one remote student object and one in-person student object. The output should show prompts to enter individual scores – midterm, finals, ...... etc. and the program will…Write a java program that Create a generic class AnimalList that has a type parameter T. It should have at least two properties declared as the passed type, constructors), getters, setters, and toString methods. Create a superclass Animal that has two properties (String, int, etc.), and constructor, getters, setters, and toString methods. Create two subclasses of Animal called Cat and Dog. Each class should have a unique property and method. Create a class Lizard with a method of your choice. Create a main class AnimalTest that creates two instances of Animal: Dog type and Cat type. Create a method that takes Animal type as parameter constraining the types to be subclasses of the Animal class only; check the type of object and call the unique method in the Dog and Cat. Create an instance of the Lizard class and test it. Display all objects.
- The Java Programming class has two types – remote and in-person. For remote students, the weighted score comprises of midterm, final, assignments and discussion. The weights for each are 30%, 30%, 30% and 10% respectively. For in-person students, the weighted score comprises of midterm, final and assignments. The weights for each are 30%, 30% and 40%. Write a generic class Students.java which has a constructor that takes three parameters – id, name, and type. Type will represent if the student is ‘remote’ or ‘in-person’. A toString() method in this class will display these details for any student. A generic method score() will be part of this class and it will be implemented by inherited classes. Write accessors and mutators for all data points. Write two classes RemoteStudents.java and InPersonStudents.java that inherits from Student class. Show the use of constructor from parent class (mind you, RemoteStudents have one additional parameter – discussion). Implement the abstract method…solve this by arraylist in the last of the question it has been told Create abstract class Pet , which is the abstract superclass of all animals. Declare a integer attribute called legs, which records the number of legs for this animal. Define a constructor that initializes the legs attribute. Declare an abstract method eat. Declare a concrete method walk that prints out something about how the animals walks (include the number of legs). Create the Dog class. The Dog class extends the Pet class. This class must include a String attribute to store the name and food of the pet Define a default constructor that calls the superclass constructor to specify that all dogs have 4 legs and name. override the eat and walk method. Create the Cat class that extends Pet. This class must include a String attribute to store the name of the pet, and a string to save food . Define a constructor that takes one String parameter that specifies the cat's name and food. This constructor must also…Q1: Write the Java code corresponding to the following UML diagram. The class School implements the interface Building. The method computeArea returns the area of the building as width * length. After that, add a testing class with a main method which defines an arrayList that contains three objects. From the main method, print the area of all the three objects.
- Write a class definition line and a one line docstring for the class Dog. Write an __init__ method for the class Dog that gives each dog its own name and breed. Test this on a successful creation of a Dog object.>>> import dog>>> sugar = dog.Dog('Sugar', 'border collie')>>> sugar.name'Sugar'>>> sugar.breed'border collie' Add a data attribute tricks of type list to each Dog instance and initialize it in __init__ to the empty list. The user does not have to supply a list of tricks when constructing a Dog instance. Make sure that you test this successfully.>>> sugar.tricks[] Write a method teach as part of the class Dog. The method teach should add a passed string parameter to tricks and print a message that the dog knows the trick.>>> sugar.teach('frisbee')Sugar knows frisbeeWrite a java program in which Animal:Create a class Animal and Add a protected data member named id of integer type.• Add get/set methods for id data member in Animal class with public access. Also provide default constructor this should initialize id to 0.• Also provide parameterized constructor and toString method.• Add an abstract method tellAboutSelf method to Animal class with public access• Add another abstract method speak method to Animal class.Reptile, Bird, MammalNext create the three child classes which extends form Animal class.• Add a default constructor to each of the above created class. The constructor should initialize the id data member id, Reptile, Bird and Mammal, to 1, 2 and 3 respectively also it display a message “(class Name)’s default constructor”. E.g. for Bird it says “Bird’s default constructor”.• Add a parameterized constructor to each of the above created class. The constructor should initialize the id data member, Reptile, Bird and Mammal, to the…Create a Cycle class, with subclasses Unicycle, Bicycle and Tricycle. Demonstrate that an instance of each type can be upcast to Cycle via a ride( ) method. Using the above Cycle hierarchy, add a balance( ) method to Unicycle and Bicycle, but not to Tricycle. Create instances of all three types and upcast them to an array of Cycle. Try to call balance( ) on each element of the array and observe the results. Downcast and call balance( ) and observe what happens.
- Answer the given question with a proper explanation and step-by-step solution. The base class Pet has protected fields petName, and petAge. The derived class Cat extends the Pet class and includes a private field for catBreed. Complete main() to: create a generic pet and print information using printInfo(). create a Cat pet, use printInfo() to print information, and add a statement to print the cat's breed using the getBreed() method.The Doctor program described in Chapter 5 combines the data model of a doctor and the operations for handling user interaction. Restructure this program according to the model/view pattern so that these areas of responsibility are assigned to separate sets of classes. The program should include a Doctor class with an interface that allows one to obtain a greeting, a signoff message, and a reply to a patient’s string. To implement the greeting, define a method named greeting for the Doctor class. To implement the signoff message, define a method named farewell for the Doctor class. Both greeting and farewell should return a string with a greeting or farewell message respectively. The reply function is defined for you, it should be added as a method for the Doctor class. The rest of the program, in a separate main program module, handles the user’s interactions with the Doctor object. Develop this program with a terminal-based user interface. Note: The program should output in the…Use the parent classes to the left to help you solve this problem. The first parent is the Person class with some very generic information. The second class, CardHolder, is the class for a credit card holder. Create the child class PlantinumClient. This class inherits all of the attributes of both parent classes. In addition, the child class has the attributes cash_back and rewards. cash_back should be set to 0.02 and rewards should be set to 0. Override the process_sale method so that 2% of each sale is added to rewards. Expected Output Declare an instance of the PlatinumClient class as shown below. platinum = PlatinumClient("Sarah", "101 Main Street", 123364) Your class should be able to execute the code below in the stated order and produce the given return values. Order Code Return Value 1 platinum.process_sale(100) N/A 2 print(platinum.rewards) 2 3 print(platinum.balance) 100 4 platinum.make_payment(50) N/A 5 print(platinum.balance)…