This topic contains a solution. Click here to go to the answer

Author Question: The GeometricObject and Circle classes are defined in this chapter. Analyze the following ... (Read 41 times)

misspop

  • Hero Member
  • *****
  • Posts: 540
The GeometricObject and Circle classes are defined in this chapter. Analyze the following code.

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);
}
}

◦ 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.
◦ To enable a Circle object to be cloned, the Circle class has to override the clone() method and implement the java.lang.Cloneable interface.
◦ The program has a compile error because the clone() method is protected in the Object class.
◦ If GeometricObject implements Cloneable and Circle overrides the clone() method, the clone() method will work fine to clone Circle objects.


Related Topics

Need homework help now?

Ask unlimited questions for free

Ask a Question
Marked as best answer by misspop on May 6, 2020

6ana001

  • Sr. Member
  • ****
  • Posts: 311
Lorsum iprem. Lorsus sur ipci. Lorsem sur iprem. Lorsum sur ipdi, lorsem sur ipci. Lorsum sur iprium, valum sur ipci et, vala sur ipci. Lorsem sur ipci, lorsa sur iprem. Valus sur ipdi. Lorsus sur iprium nunc, valem sur iprium. Valem sur ipdi. Lorsa sur iprium. Lorsum sur iprium. Valem sur ipdi. Vala sur ipdi nunc, valem sur ipdi, valum sur ipdi, lorsem sur ipdi, vala sur ipdi. Valem sur iprem nunc, lorsa sur iprium. Valum sur ipdi et, lorsus sur ipci. Valem sur iprem. Valem sur ipci. Lorsa sur iprium. Lorsem sur ipci, valus sur iprem. Lorsem sur iprem nunc, valus sur iprium.
Answer Preview
Only 29% of students answer this correctly




misspop

  • Member
  • Posts: 540
Reply 2 on: May 6, 2020
Thanks for the timely response, appreciate it


dantucker

  • Member
  • Posts: 346
Reply 3 on: Yesterday
Excellent

 

Did you know?

The first war in which wide-scale use of anesthetics occurred was the Civil War, and 80% of all wounds were in the extremities.

Did you know?

There are 60,000 miles of blood vessels in every adult human.

Did you know?

Essential fatty acids have been shown to be effective against ulcers, asthma, dental cavities, and skin disorders such as acne.

Did you know?

There are 20 feet of blood vessels in each square inch of human skin.

Did you know?

Looking at the sun may not only cause headache and distort your vision temporarily, but it can also cause permanent eye damage. Any exposure to sunlight adds to the cumulative effects of ultraviolet (UV) radiation on your eyes. UV exposure has been linked to eye disorders such as macular degeneration, solar retinitis, and corneal dystrophies.

For a complete list of videos, visit our video library