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 42 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
YES! Correct, THANKS for helping me on my review


Jossy

  • Member
  • Posts: 336
Reply 3 on: Yesterday
Thanks for the timely response, appreciate it

 

Did you know?

The effects of organophosphate poisoning are referred to by using the abbreviations “SLUD” or “SLUDGE,” It stands for: salivation, lacrimation, urination, defecation, GI upset, and emesis.

Did you know?

The toxic levels for lithium carbonate are close to the therapeutic levels. Signs of toxicity include fine hand tremor, polyuria, mild thirst, nausea, general discomfort, diarrhea, vomiting, drowsiness, muscular weakness, lack of coordination, ataxia, giddiness, tinnitus, and blurred vision.

Did you know?

Adolescents often feel clumsy during puberty because during this time of development, their hands and feet grow faster than their arms and legs do. The body is therefore out of proportion. One out of five adolescents actually experiences growing pains during this period.

Did you know?

More than 50% of American adults have oral herpes, which is commonly known as "cold sores" or "fever blisters." The herpes virus can be active on the skin surface without showing any signs or causing any symptoms.

Did you know?

The average adult has about 21 square feet of skin.

For a complete list of videos, visit our video library