Exercise 1b        Name __________________        Score __/9

Modified: 

Use the following Java class definition for exercise questions:

  1. (2) Sketch the class diagram for the following:
     
     public class A
     {
     private B b;
     private C c;
     }
     public class B
     {
     private C c;
     private int bi;
     }
     public class C
     {
     private int ci;
     }

     

  2. (3) Sketch the complete object diagram for the following after completing execution of:

            A a = new A();
     
     public class A
     {
     private B b;
     private C c;

     

     public A ()
     {
         b = new B();
         c = new C(1);
     }

     public class B
     {
     private C c;
     private int bi;

     

     public B ()
     {
         c = new C(2);
         bi = 3;
     }
     }
     public class C
     {
     private int ci;

     

     public C (int z)
     {
         ci = z;
     }
     }


     

  3. (4) What is the result of the following?

    Assume:
        x = 13
       
    1. x % 5
    2. x + 1 % 2
    3. "123"+x
    4. if (x > 0 && x < 10)
             System.out.println("Smile, you're done");
      else System.out.println("Smile Bigger, you're done and right");