Here in the following java code of Test2 class, there are two variables named

Here in the following java code of Test2 class, there are two variables named a.Here I would like to know what is the difference between the two variables.And, also please let me know what concept does the output of the last three print statements demonstrate?
Rectangle.java
public class Rectangle
{
public int length;
public int width;
public Rectangle(int l, int w)
{
length = l;
width = w;
}
public Rectangle(int l)
{
this(l, 10);
}
public Rectangle(Rectangle other)
{
this(other.length, other.width);
}
}
Test2.java
public class Test2
{
static int a;
public static void main(String[] args)
{
Rectangle box1 = new Rectangle(10,10);
Rectangle box2 = new Rectangle(box1);
Rectangle box3 = new Rectangle(10);
Rectangle box4 = box1;
box1 = null;
System.out.println("box(l,w) = (" + box2.length + "," + box2.width + ")");
System.out.println("box(l,w) = (" + box3.length + "," + box3.width + ")");
System.out.println("box(l,w) = (" + box4.length + "," + box4.width + ")");
System.out.println("All of the above produce the same output!!!");
box2 = null;
System.out.println("n");
a = 1;
System.out.println("a = " + a);
int a;
a = 101;
System.out.println("a = " + a);
System.out.println("a = " + Test2.a);
 GET THIS PAPER COMPLETED FOR YOU FROM THE WRITING EXPERTS  CLICK HERE TO ORDER 100% ORIGINAL PAPERS AT PrimeWritersBay.com

Comments

Popular posts from this blog

Create Thread”. Do not create a new forum.

Discuss the notion that firms should stop doing business with customers who constantly generate losses versus the notion that the customer is always right.

Access AHIMA: What is Health Information