Answer to Question #3469 in Java | JSP | JSF for Y mukundareddy
(1) Write a program to declare any variables as public and access them in another class as you seen in the examples?
1
2011-08-03T16:00:30-0400
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!
Learn more about our help with Assignments:
JavaJSPJSF
Comments
Leave a comment