Pet class has already been defined
and you expect the Cat class to be used freely throughout the
application, please answer the following questions:
Cat
class, up to but not including the first opening brace?
Use only these words and spaces: boolean, Cat, class, Date,
extends, Object, Owner, Pet, private, protected, public, String.
Cat class as members?
| A. | Pet thePet; |
|---|---|
| B. | Date registered; |
| C. | Date vaccinationDue; |
| D. | Cat theCat; |
| E. | boolean neutered; |
| F. | String markings; |
public class Bob extends Cloneable {
protected Bob clone() {
return this;
}
public static int main(String[] args) {
Bob[] msoft = new Bob[1000];
Bob team [1000];
for (int j = 0; j < msoft.length(); j++) {
team[j] = msoft[j].clone();
}
delete msoft[];
}
}
Answer:
SwapChar that takes a string and two
integers as command-line arguments. The program should print out
a modified string obtained from the original string by swaping two
characters at positions specified by the two integers. For example,
suppose that you enter the following:
java SwapChar oat 0 2
The program should display
tao
and exit. In addition, your program should catch and handle all
exceptions that might arise because of a bad input.
Each type of exception should be handled independently, by printing an
appropriate error message which would specify what exactly was wrong
with the input. Hint: please remember that invalid array access
causes ArrayIndexOutOfBoundsException. You might also find
useful some of the following methods:
public static int java.lang.Integer.parseInt(String s)
throws NumberFormatException;
public char java.lang.String.charAt(int index)
throws IndexOutOfBoundsException;
public char java.lang.StringBuffer.charAt(int index)
throws IndexOutOfBoundsException;
public void java.lang.StringBuffer.setCharAt(int index, char c)
throws IndexOutOfBoundsException;
public java.lang.StringBuffer java.lang.StringBuffer.append(char c);