60 371
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #3469 in Java | JSP | JSF for Y mukundareddy

Question #3469
(1) Write a program to declare any variables as public and access them in another class as you seen in the examples?
Expert's answer
public class Task1
{
public static void main(String[] args)
{
& Rectangle r1 = new Rectangle(5, 10);
& System.out.print("Rectangle: width = " + r1.width + ", height = " + r1.height);
}
}

class Rectangle
{
public int width;
public int height;

Rectangle(int pWidth, int pHeight)
{
& width = pWidth;
& height = pHeight;
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions