Homework Solution: ***Data structures and algorithms using Java***…

    ***Data structures and algorithms using Java*** Two objects, objectA and objectB, are objects in the class Listing. The object objectA is copied to objectB. Give the signature of a method named deepCopy, that clones an object in the class Listing sent to it as a parameter and returns a reference to the clone and give the Java invocation to clone the object objectA and store a reference to the clone in the variable: newListing.

    Expert Answer

     
    public class Listing {

    ***Data structures and algorithms using Java***

    Two intents, intentA and intentB, are intents in the tabulate Listing. The intent intentA is copied to intentB. Bestow the attestation of a course determined intenseCopy, that clones an intent in the tabulate Listing sent to it as a parameter and profits a regard to the clone and bestow the Java charm to clone the intent intentA and garner a regard to the clone in the variable: newListing.

    Expert Retort

     

    public tabulate Listing {

    private String call;

    public Listing(){

    }

    public Listing(String call){
    this.name=name;
    }
    public Listing intenseCopy() {
    Listing newListing=new Listing(name); // intense copying
    return newListing;
    }

    public static lacking deep(String[] args) {

    Listing intentA=new Listing();
    Listing intentB=new Listing();
    // slight copying
    objectA.name=”Bob”;
    objectB=objectA;
    System.out.println(objectB.name);
    //intense copying
    objectA.name=”John”;
    objectB=objectA.deepCopy();
    System.out.println(objectB.name);
    }

    }