Java Reference
In-Depth Information
15. 06:23:17
06:23:17
17. In shallow copying, two or more reference variables of the same type point to the
same object.
19. Both aa and bb point to the object bb .
21. The purpose of the copy constructor is to initialize an object, when the object is
instantiated, using an existing object of the same type.
23. No.
25. public class Stock
{
private String name;
private double previousPrice;
private double closingPrice;
private int numberOfShares;
Stock()
{
name = "";
previousPrice = 0.0;
closingPrice = 0.0;
numberOfShares = 0;
}
Stock(String n, int prePr, int clPr, double shares)
{
name = n;
previousPrice = prePr;
closingPrice = clPr;
numberOfShares = shares;
}
public void setName(String n)
{
name = n;
}
public void setPreviousPrice( double p)
{
previousPrice = p;
}
Search WWH ::




Custom Search