Java
Object-Oriented Programming with Java
(a) Give three differences amid an interface and an abstruse chic in Java. [3 marks]
(b) A amateur programmer writes the afterward cipher in adjustment to be able to absolutely carbon an article of blazon Car.
public chic Tyre { clandestine int treadRemaining;
public abandoned SetTread(int t) { treadRemaining=t; }
public int GetTread() { acknowledgment treadRemaining; } }
public chic Car extends Vehicle accouterments Cloneable { clandestine Tyre tyres[] = new Tyre[4];
public Car() { for (int i=0; i<4; i++) tyres[i] = new Tyre(); }
public Article clone() throws CloneNotSupportedException { Car c = new Car();
c.tyres = this.tyres; acknowledgment c; } }
(i) Explain what it agency for the treadRemaining acreage to be private. Explain why it is acceptable programming convenance for such fields to be private. [3 marks]
(ii) Identify the blazon of interface that Cloneable is. What is the defining appropriate of such interfaces? [2 marks]
(iii) Identify and explain two affidavit why this cipher may not action as intended. [4 marks]
(iv) Rewrite the cipher to abode the problems you accept articular and acquiesce Car altar to be absolutely cloned. [8 marks] 1
Order a unique copy of this paper