| Java OOP GUIDE / WORK 
 RECTANGLE CLASS 1
  SOLUTIONS TASK – CODE
  ANALYSIS QUESTIONS Consider
  the following class and answer the questions at the bottom: 
 a)   
  What
  is the name of the class?  b)   
  What
  is the name of the file that this code gets stored into? c)    
  How
  many instance variables do this class have? d)   
  How
  many datafields do this class have? e)   
  How
  many constructors does this class have? f)     
  How
  many instance methods does this class have? g)   
  What
  type of data does the toString() method return? h)   
  Which
  instance variables does the toString() method use? i)      
  What
  type of data does the area() method return? 
 j)      
  Which
  instance variables does the area() method use? Answer: w and h k)    
  Write
  the code needed to create a rectangle that has (x,y) = (4,9), a width of 6, a height of 3 and a
  “red” colour.           Answer:           r.x = 4;          r.y = 9;          r.w = 6;          r.h = 3;      r.colour = "red"; l)      
  Where
  would your place the above code to construct the rectangle? m)  
  What
  is the statement needed to output to screen the area of the rectangle that
  you created above?             System.out.println(r.area()); | |
| 
 |