1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Alisiya [41]
3 years ago
13

Define a method printAll() for class PetData that prints output as follows with inputs "Fluffy", 5, and 4444. Hint: Make use of

the base class' printAll() method.
Name: Fluffy, Age: 5, ID: 4444
// ===== Code from file AnimalData.java =====
public class AnimalData {
private int ageYears;
private String fullName;
public void setName(String givenName) {
fullName = givenName;
}
public void setAge(int numYears) {
ageYears = numYears;
}
// Other parts omitted
public void printAll() {
System.out.print("Name: " + fullName);
System.out.print(", Age: " + ageYears);
}
}
// ===== end =====
// ===== Code from file PetData.java =====
public class PetData extends AnimalData {
private int idNum;
public void setID(int petID) {
idNum = petID;
}
// FIXME: Add printAll() member function
/* Your solution goes here */
}
// ===== end =====
// ===== Code from file BasicDerivedOverride.java =====
import java.util.Scanner;
public class BasicDerivedOverride {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
PetData userPet = new PetData();
String userName;
int userAge;
int userID;
userName = scnr.next();
userAge = scnr.nextInt();
userID = scnr.nextInt();
userPet.setName(userName);
userPet.setAge (userAge);
userPet.setID (userID);
userPet.printAll();
System.out.println("");
}
}
// ===== end =====

Computers and Technology
1 answer:
QveST [7]3 years ago
8 0

Answer:

public void printAll(){  // member function petAll()

   super.printAll();  //  calls printAll() method of the superclass (base class) AnimalData using super keyword

   System.out.print(", ID: " + idNum);} // prints the ID stored in the idNum data member of the PetData class

Explanation:

Here is the complete PetData class:

public class PetData extends AnimalData {  //

private int idNum;

public void setID(int petID) {

idNum = petID;  }

// FIXME: Add printAll() member function

/* Your solution goes here */

public void printAll(){

   super.printAll();

   System.out.print(", ID: " + idNum);}  }

PetData class is a subclass which is inherited from the base class AnimalData.

This class has a private data member which is the variable idNum which is used to store the ID value.

It has a member function setID with parameter petID which is the idNum. This method basically acts as a mutator and sets the user ID.

This class has another method printAll() that uses super keyword to access the method printAll() of the base class which is AnimalData

super basically refers to the base class objects.

Here the super keyword is used with the method name of subclass PetData in order to eliminate the confusion between the method printAll() of AnimalData and PetData since both have the same method name.

In the main() method the use is prompted to enter values for userName, UserAge and UserID. Lets say user enters Fluffy as user name, 5 as user age and 4444 as userID. Then the statement userPet.printAll(); calls printAll() method of PetData class as userPet is the object of PetData class.

When this method is called, this method calls printAll() of AnimalData class which prints the Name and Age and printAll() of PetData class prints the ID. Hence the program gives the following output:

Name: Fluffy, Age: 5, ID: 4444    

You might be interested in
Billy used to take care of his laptop. However, one day he lost his laptop. He lost all his data, and there was no way to retrie
katrin [286]
D he didnt have backup obv

5 0
3 years ago
Read 2 more answers
Write about virus in five points.​
kvasek [131]
A computer virus is a malicious software program loaded onto a user's computer without the user's knowledge and performs malicious actions. It can self-replicate, inserting itself onto other programs or files, infecting them in the process.
5 0
2 years ago
________ is the application of statistical techniques to find patterns and relationships among data for classification and predi
Finger [1]

Answer:          

Data Mining

Explanation:

  • Data Mining is also called knowledge discovery.
  • It is a computer aided technique of searching and evaluating a bulk of data in order to obtain useful information.
  • This technique searches through the data to find hidden patterns and uses statistical methods to find relationship among data for finding predictive information and for classification of data.
  • This is a mixture of different disciplines which include machine learning, statistics and artificial intelligence and also some mathematical methods.
  • Often the useful information is extracted from enormous database using modeling technique which is used to build a model from instances of the data where the solution is known and later apply this model on the instances where the solution is unknown.
  • In unsupervised data mining, the data analysis is not done by using modeling technique. In other words the labels are provided in order not draw inferences and prediction from data sets. Example is clustering.
  • In supervised data mining the model is developed to make inferences and classification. Example is neural networks.
  • For example data mining is used in Medicine industry to provide more accurate diagnostics and treatments on the basis of patient's medical history , physical examination or different patient tests data.
  • Data mining also makes it possible to manage health resources more efficiently and cost-effectively by detecting risks, predicting diseases in certain sections of the population or predicting hospitalization duration.
4 0
3 years ago
6 The part of the computer that contains the brain or central processing unit is also known as the ?
Olin [163]
Answer:  "CPU" .
________________________________
4 0
3 years ago
Technician A says that high pressure in recycled refrigerant is only caused by air contamination. Technician B says that recycle
hjlf

Answer:

a. A only

Explanation:

When air, is in excess of allowable amounts, it  can cause the system to operate at pressures that are higher than normal. This means that the recycled refrigerant is operating at high pressure. Thus Technician A is correct.

However, Technician B is incorrect because unlike reclaimed refrigerants where the process strip the refrigerant of impurities making it to meet the standards of a new refrigerant, the recycled refrigerant is not as pure as it's contaminants are only reduced.

Therefore, only technician A is correct.

6 0
3 years ago
Other questions:
  • The score of a student in two subjects are inserted in the B2 and C2 cells and the passing score for each subject is 60. Which o
    13·1 answer
  • Customers access the internet through what usually for a monthly fee
    14·1 answer
  • Emotional intelligence is a new term to describe personal traits ?
    12·1 answer
  • Write a program with a function that accepts a string as an argument and returns a copy of the string with the first character o
    11·1 answer
  • If you have a document that is relevant to more than one folder in your computer what should you do?
    8·1 answer
  • When a climbing distance of __________, landing platforms must be in place every __________ feet. Platforms will be offset from
    12·1 answer
  • What are the origins of the parking barrier?
    12·1 answer
  • Write a program that declares three one-dimensional arraysnamed miles, gallons, and mpg. Each array should be declared in main()
    10·1 answer
  • HELPPPPP 20 POINTS CORRECT ANSWER GETS BRAINLIEST<br>sorry wrong amount of points ;-;
    13·2 answers
  • GIF is example of raster image<br><br><br> RIGHT OR WRONG?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!