What is the defining characteristic of such interfaces


Problem: Object-Oriented Programming with Java

• Give three differences between an interface and an abstract class in Java.

• A novice programmer writes the following code in order to be able to completely clone an object of type Car.

public class Tyre { private int treadRemaining;
public void SetTread(int t) { treadRemaining=t; }
public int GetTread() { return treadRemaining; } }
public class Car extends Vehicle implements Cloneable { private Tyre tyres[] = new Tyre[4];
public Car() { for (int i=0; i<4; i++) tyres[i] = new Tyre(); }
public Object clone() throws CloneNotSupportedException { Car c = new Car();
c.tyres = this.tyres; return c; } }

• Explain what it means for the treadRemaining field to be private. Explain why it is good programming practice for such fields to be private.

• Identify the type of interface that Cloneable is. What is the defining characteristic of such interfaces?

• Identify and explain two reasons why this code may not function as intended.

• Rewrite the code to address the problems you have identified and allow Car objects to be fully cloned.

The response should include a reference list. Using double-space, Times New Roman 12 pnt font, one-inch margins, and APA style of writing and citations.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: What is the defining characteristic of such interfaces
Reference No:- TGS03130909

Expected delivery within 24 Hours