7  | Open the dome-v2 project. Add a class for video games to the project. Create some video game objects and test that all the methods work as expected. 
  | Done!  | 
8  | Order these items into an inheritance hierarchy: apple, ice cream, bread, fruit, food-item, cereal, orange, dessert, chocolate mousse, baguette.  | Super class - Food-items and has dessert, apple, cereal, orange, and bread as its sub classes. Dessert is a superclass for subclasses ice-cream and chocolate mousse. Class bread is superclass now and has baguette as its subclass.  | 
9  | In what inheritance relationship might a touch pad and a mouse be?  | They could be the sub-classes of Computer parts.  | 
10  | 
  | Every square is rectangle but every rectangle is not square. Therefore, square is a subclass of rectangle.  | 
11  | Assume we have four classes: Person, Student, Teacher & PhDStudent. Teacher and Student are both subclasses of Person. PhDStudent is a subclass of Student. Which of the following assignments are legal and why? Person p1 = new Student(); Person p2 = new PhDStudent(); PhDStudent phd1 = new Student(); Teacher t1 = new Person(); Student s1 = new PhDStudent(); s1 = p1; s1 = p2; p1 = s1; t1 = s1; s1= phd1; phd1 = s1;  | Person p1 = new Student() because a student is a person. Person p2 = new PhDStudent(); becausea phDStudent is a person.  Student s1 = new PhDStudent(); because a PhDStudent is a Student.  p1 = s1 because student is a person.  s1 = phd1 because a PhD student s a student.   | 
12  | Test your answers to the previous question by creating the classes mentioned in that exercise, and trying it out in BlueJ.  | Woohoo! its right :)  | 
13  | What has to change in the Database class when another item subclass (for example classVideoGame) is added? Why? 
  | Only have to add "extends" to VideoGame class.  | 
14  | Use the documentation of the standard class libraries to find out about the inheritance hierarchy of the collection classes. Draw a diagram showing the hierarchy. http://java.sun.com/j2se/1.4.2/docs/api/ 
  | |
15  | Go back to the lab-classess project from chapter 1. Add instructors to the project. Use inheritance to avoid code duplication between students and instructors.  | Done!  | 
16  | Draw an inheritance hierarchy representing parts of a computer system (processor, memory, disk drive, CD drive, printer, scanner, keyboard, mouse, etc.)  | Done on paper  | 
17  | Look at the code below. You have four classes (O,X,T and M) and a variable of each of these. O o; X x; T t; M m; The following assignments are all legal. m = t; m = x; o = t; The following assignments are all illegal. o = m; o = x; x = o; What can you say about the relationships of these classes?  | Done on paper  | 
18  | Draw an inheritance hierarchy of AbstractListand all its (direct and indirect) subclasses, as they are defined in the Java standard library. http://java.sun.com/j2se/1.4.2/docs/api/ 
  | Done on paper!  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
  | 
No comments:
Post a Comment