Wednesday
June 19, 2013

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 ...
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...
shabou - Can someone please make a Binarytree of these methodes in Java?: public...
Java - I am supposed to convert a program i already made into a Java console ...
Java programming - List all overloading methods (including constructors) in this...
java programming - Provide a class called Letter for authoring a simple letter. ...
computer science - i have two numbers... 1564656 1981676 i want to check if the ...
Computer Sciene-java - Write a loop that will continuously prompt the user for ...

For Further Reading

Search
Members
Community