CS 1713 Practice Problems on Drawing Diagrams


  1. Draw an accurate schematic of the program variables showing the execution of the program.
       double a = 2.0;
       double b = 3.0;
       double c;
       c = 5.6;
       b = a;
       a = 9.2;
    
    solution
    
    
    
    
  2. Suppose Rectangle is a class that has been appropriately written. Draw an accurate schematic of the program variables showing the execution of the program.
      double len;
       double wid;
       double perimeter;
       Rectangle rect1;
       Rectangle rect2;
       len = 7;
       wid = 9;
       rect1 = new Rectangle(wid, len);
       perimeter = rect1.getPerimeter();
       rect2 = rect1;
       rect1.setWidth(4);
       perimeter = rect2.getPerimeter();
    
    solution
    
    
    
    
  3. Draw an accurate schematic of the program variables showing the execution of the program.
    int[] a = {1, 3, 5, 7};
    int[] b = {2, 4};
    int[] c;
    c = a;
    c[1] = 9;
    c = b;
    c[1] = 8;
    a = b;
    a[0] = 6;
    
    solution