Thursday
April 17, 2014

Homework Help: Programming

Posted by Rob on Wednesday, October 28, 2009 at 2:17am.

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).

Answer this Question

First Name:
School Subject:
Answer:

Related Questions

Programming - The code below shows some of the text for a class called City. Now...
programming - m trying to create an arraylist that's sorted but I have no idea ...
Java Panel Problem - I am supose to draw a grid and center it with a 10 pix ...
computer science - Im trying to create an arraylist that's sorted but I have no ...
shabou - Can someone please make a Binarytree of these methodes in Java?: public...
Java programming - List all overloading methods (including constructors) in this...
Computer - Question 1 In the code below, there is an ambiguous reference in the ...
java programming - Provide a class called Letter for authoring a simple letter. ...
Java - I am supposed to convert a program i already made into a Java console ...
Computer Science-Java - Hi, I have to write a method that returns my first name...

Search
Members