The GeometricObject and Circle classes are defined in this chapter. Analyze the following code. Which statements are correct?

```
public class Test {
public static void main(String[] args) {
GeometricObject x = new Circle(3);
GeometricObject y = (Circle)(x.clone());
System.out.println(x);
System.out.println(y);
}
}```
a. The program has a compile error because the clone() method is protected in the Object class.
b. After you override the clone() method and make it public in the Circle class, the problem can compile and run just fine, but y is null if Circle does not implement the Cloneable interface.
c. To enable a Circle object to be cloned, the Circle class has to override the clone() method and implement the java.lang.Cloneable interface.
d. If GeometricObject implements Cloneable and Circle overrides the clone() method, the clone() method will work fine to clone Circle objects.


abcd

Computer Science & Information Technology

You might also like to view...

Which of the following statements is true?

a. The Internet is just a network of computers. b. The internet is now an Internet of Things. c. Each thing in the Internet of things is an object with an IP address. d. Each thing in the Internet of Things must have the ability to send data automatically over a network.

Computer Science & Information Technology

A hard drive must be mounted in the system unit

Indicate whether the statement is true or false

Computer Science & Information Technology

Facebook is the world's largest social network, where hundreds of millions of users connect with friends, family, and colleagues

Indicate whether the statement is true or false

Computer Science & Information Technology

An author can identify the changes a reviewer has made by looking at the ____ in a document.

A. tracks B. mashups C. status marks D. markups

Computer Science & Information Technology