Here is the source code for the Kitty class:
public class Kitty {

String name;
int age;

public Kitty(){

public void setName(String n){
name = n;

public String getName(){
return name;

public void setAge(int a){
age = a;

public int getAge(){
return age;

1) The array myCats is an 8 element array of type Kitty that has already been declared and initialized. Write the expression(s) in the box below that increases the age of the fifth Kitty by one year:

(Remember: the first element of an array is at index position 0).

2)The array myCats is an 8 element array of type Kitty that has already been declared and initialized. Write the expression(s) in the box below that prints to the console the name of the fourth Kitty if its age is strictly greater than the age of the fifth Kitty, and prints the name of the fifth Kitty otherwise:

(Remember: the first element of an array is at index position 0).

  1. 👍
  2. 👎
  3. 👁
  1. The fifth Kitty is myCats[4], since the index starts from zero.
    Each member of the array myCats is a Kitty object.

    To increase the age, you need to get the age of myCats[4], add one to it, and put back the increased age. This is how you can do it:

    int age4=myCats[3].getAge();
    int age5=myCats[4].getAge();
    } else
    ... to be completed by you ...

    1. 👍
    2. 👎
  2. System.out.print(myCats[4].getName());

    1. 👍
    2. 👎

Respond to this Question

First Name

Your Response

Similar Questions

  1. Java Programming

    1. Which of the following is not the name of a Java wrapper class from the Java API? A. Byte B. Int C. Long D. Boolean* 2. Which of the following statements will cause a compiler error? A. Integer i = new integer ( ) ;* B. Integer

  2. spanish

    escribe que clases tienen estas personas, usando formas de tener. 1. yo a picture of a math class 2. nosotros a picture of an english class 3. claudia y pablo science class 4. tu art class 5. claudia history class 6. ustedes

  3. java programming

    Dice Game Write a program that plays a simple dice game between the computer and the user. When the program runs, a loop should repeat 10 times. Each iteration of the loop should do the following: Generate a random integer in the

  4. English

    (Excerpt from Chapter 7 of Anna Karenina, by Leo Tolstoy) 7. How does the style of the passage connect to the theme of maintaining the social order? A. Its vivid description of numerous characters shows that changes are coming to

  1. programming

    A hotel’s occupancy rate is calculated as follows: Occupancy rate = number of rooms occupied total number of rooms Write a program that calculates the occupancy rate for each fl oor of a hotel. The program should start by asking

  2. Computers(Java Programming)

    Service Class: Lottery Write a Lottery class that simulates a lottery. The class should define an array of five integers named lotteryNumbers. The constructor should use the Random class (see the Java API) to generate a random

  3. Science/Computer Programming

    The purpose of this exercise is to practice reading code and recognizing the traversal patterns in this chapter. The following methods are hard to read, because instead of using meaningful names for each variable and method, they

  4. Art

    based on their attire, playing music during leisure time is most likely a pursuit of which greek class citizen? lower class musical class upper class middle class i believe it is upper class

  1. Java Programming

    1. What is Java SE? A. Java Standard Edition* B. Java Software Editor C. Java Scientific Edition D. Java Software Emulator 2. Which of the following is the correct header for the main method of a Java program? A. public static

  2. Computer Science Computer Programming

    Please help! I cannot figure out what I am doing wrong. I cannot get the correct output when I run the system. Here is what I have entered in to Netbeans IDE: package shippingcharges; public class ShippingCharges { private double

  3. math

    Problems continue to arise in Kitty Nation but Hello Kitty has regained control of the country. She comes to see that popular dislike for the own measurement standard led to the revolt. She decides to change the standard so that

  4. Math ~ CHECK ANSWER

    Below are two sets of student quiz scores on a 30-point quiz. Which of the following can you conclude by comparing their box-and-whisker plots? Class A: 5, 10, 13, 18, 19, 25, 29 Class B: 1, 3, 5, 7, 9, 9, 13 a) The first quartile

You can view more similar questions or ask a new question.