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
Allushta [10]
2 years ago
9

The cat store needs your help! The base class Animal has private fields animalName, and animalAge. The derived class Cat extends

the Animal class and includes a private field for catBreed. Complete main() to:
create a generic animal and print information using printInfo().
create a Cat animal, use printInfo() to print information, and add a statement to print the cat's breed using the getBreed() method.
Ex. If the input is:
Dobby
2
Kreacher
3
Maine Coon
the output is:
Pet Information:
Name: Dobby
Age: 2
Pet Information:
Name: Kreacher
Age: 3
Breed: Maine Coon
AnimalIformation.java
import java.util.Scanner;
public class AnimalInformation {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
Animal myAnimal = new Animal();
Cat myCat = new Cat();
String animalName, catName, catBreed;
int animalAge, catAge;
animalName = scnr.nextLine();
animalAge = scnr.nextInt();
scnr.nextLine();
catName = scnr.next();
catAge = scnr.nextInt();
scnr.nextLine();
catBreed = scnr.nextLine();
// TODO: Create generic animal (using animalName, animalAge) and then call printInfo
// TODO: Create cat animal (using catName, catAge, catBreed) and then call printInfo
// TODO: Use getBreed(), to output the breed of the cat
}
}
Animal.java
public class Animal {
protected String animalName;
protected int animalAge;
public void setName(String userName) {
animalName = userName;
}
public String getName() {
return animalName;
}
public void setAge(int userAge) {
animalAge = userAge;
}
public int getAge() {
return animalAge;
}
public void printInfo() {
System.out.println("Animal Information: ");
System.out.println(" Name: " + animalName);
System.out.println(" Age: " + animalAge);
}
}
Cat.java
public class Cat extends Animal {
private String catBreed;
public void setBreed(String userBreed) {
catBreed = userBreed;
}
public String getBreed() {
return catBreed;
}
}
Computers and Technology
1 answer:
Nat2105 [25]2 years ago
8 0

Answer:

Answered below

Explanation:

//TODO1

myAnimal.setName(animalName);

myAnimal.setAge(animalAge);

myAnimal.printInfo();

//TODO2

myCat.setName(catName);

myCat.setAge(catAge);

myCat.setBreed(catBreed);

myCat.printInfo();

//TODO

//Call the getter method of the cat class and //save the returned string in a variable to print //it out.

String breed = myCat.getBreed();

System.out.print(breed);

You might be interested in
C program how to input this? ​
Neporo4naja [7]
Chchvjvcuvggiiog. Correct
3 0
2 years ago
Anyone from qls<br><br>or grax here<br><br>in bs​
PIT_PIT [208]

Answer:

No, I don't think I've ever heard of DLS or Grax either if I'm being honest.

May I have brainliest please? :)

7 0
2 years ago
Which of the following lines correctly defines a String variable
lidiya [134]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The correct answer to this question is C i.e. String s = "apluse";

The rule or syntax of declaring string in any programming language is given below:

String variable-name = "yourString";

For declaring string variable, first, you write "String" that is a keyword of a programming languages for declaring string variables, such as int before the variable name for declaring integer variable. Then, you need to write a meaningful name of the string as a variable. After string variable name, you need to put the equal operator and then write the string in double quotation("") marks and after that put the instruction terminator that is ";".

So, according to this syntax, option C is correct.

While other options are not correct because:

In option a, string is not encapsulated in double quotation. Option B does not have varaible type such as String and Option E does not have variable name and its value also. So, only option C is correct and all other except C are incorrect.

3 0
2 years ago
. What is an APT? What are some practical strategies to protect yourself from an APT?
viva [34]

Answer and Explanation:

Advanced Persistent Threat abbreviated as APT is a type of cyber attack which gives access to the unauthorized user  to enter the network without being detected for a long period.

APTs are generally sponsored by the government agencies of the nation or large firms. For example, one of the ATPs used was Stuxnet in the year 2010 against Iran, in order to put off the nuclear program of Iran.

Some of the practical strategies for protection against APT are:

  • Sound Internal Auditing
  • Strong Password Accessing Policies
  • Stringent policies for accessing any device
  • Introduction and implementation of multi factor authentication
  • Strong IDs and sound honeypot solutions
3 0
3 years ago
Which of the following are computer safety techniques? Check all of the boxes that apply.Identify Computer Safety Techniques:
zvonat [6]

Answer: Protect the system with a password  

               Use spam protection.

               Avoid using questionable software.

               

Explanation:

4 0
3 years ago
Other questions:
  • The java compiler requires that a source file use the ________ filename extension question 3 options: 1) .class 2) .h 3) .java
    8·1 answer
  • Which player type focuses on level progression?
    13·1 answer
  • What is a binary message
    12·2 answers
  • 4
    5·1 answer
  • "A user reports that the corporate web server cannot be accessed. A technician verifies that the web server can be accessed by i
    8·1 answer
  • What technology has a function of using trusted third-party protocols to issue credentials that are accepted as an authoritative
    12·1 answer
  • Whats yall favv scary movie
    11·1 answer
  • Which view would you need to use to make changes to the design theme for the entire presentation?
    10·2 answers
  • Question #4
    7·1 answer
  • Your friend says, “I can’t ever watch a streaming movie without it pausing for long moments. It makes me crazy!” What might you
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!