Midterm Review
Midterm/Tutorials/CT
- Midterm exam is scheduled for Wednesday, March 9, 6:00pm. (KNB132 for L01 with Dr. Manzara)
- Tutorials are cancelled for Wednesday and Thursday (March 9 and 10)
- CT hours are still ongoing this week
Extra help hours
- Me: ICT 524, Tuesday night and Wednesday before 2pm, email me.
- Dr. Manzazra: ICT 502, Wednesday 2-5pm
- Prof. Said: ICT 703, Wednesday 10-11am
Midterm format
- 30 multiple choice
- 1 coding question
- 1 UML question
Midterm topics (sections/chapters based on 6th edition textbook)
From the professor:
- Declaring a class (Section 4.1)
- Declaring instance variables and class (static) variables (Section 4.1, 5.1)
- Declaring instance methods and class (static) methods (Section 4.1, 5.1)
- Instantiating objects using the new operator (Section 4.1, page 207)
- Difference between declaration and instantiation
- Deep vs shallow copies
- Primitive data types vs Classes
- Creating a subclass by using the extends keyword (Chapter 7)
- A class that has more than one type (isinstanceof Shape and instanceof Circle for example) is polymorphic (Section 8.1)
- Review A3, know how to draw this in UML diagram (Section 12.1)
- Overriding methods and constructors in a subclass (Chapter 7)
- Know how to use this and super keywords (Section 7.1)
- Review A2 and A3 for constructors
- Review A3 for overriding
- Creating abstract classes and final classes (Chapter 8,
- Know what abstract means
- abstract classes cannot be instantiated, you have to subclass/extend them
- abstract methods have no implementation/code, you have to override them in your subclass
- Know what final means
- final classes cannot be subclassed
- final methods cannot be overridden
- final variables (constants) cannot be changed after instantiation (you can assign the value only once with "=") (Section 1.2)
- Know what abstract means
- Creating an aggregation/composition relationship in Java
- Review A3, know how to draw this in UML diagram (Section 12.1)
- Both aggregation and composition are types of association
- Aggregation means that the two classes are related, but the classes can exist on their own (eg. a Classroom and a Student; a Classroom can be empty, a Student doesn't need to be in a Classroom)
- Composition means that the two classes are related, but the classes cannot exist on their own (eg. a Person and a Hand; Hand cannot exist without a Person)
- Creating and using arrays (Chapter 6)
- Arrays cannot be resized
- Empty array elements store a null value
- Array indices start at 0
- Use arrayName.length to get the size (number of elements it can store, not number of elements you are currently storing; empty values are null, but the length of the array doesn't change)
- Use arrayName.length in a For loop to iterate through the array: for(int i = 0; i < arrayName.length; i++){//do something}
- With an array, you should iterate through it to find a value. With an arrayList, you can use arrayListName.indexOf(element).
- To access an element at index i, use arrayName[i] = ...
- Drawing basic class diagrams in UML (Section 12.1)
- Example for A3
- Review A2 and especially A3 UML diagrams
- Association: aggregation and composition
- Extends (inheritance)
Additional:
- private/protected/public, know the difference (Section 4.2)
- instance variables should usually be private (Section 4.2)
- use public or protected instance methods to access private instance variables (accessor/get and mutator/set methods) (Section 4.2)
- variable scope (Tracer question: see if you know what m2() method is really doing) (Section 4.1, local variables)
- integer/floating-point division, type casting (Section 1.2)
- increment and decrement operators (Section 1.2)
- branching (if, if-else, else) (Section 3.1)
- loops (Section 3.3)
- Math.random(), java.util.Random (Section 3.5)
Assigned textbook readings in lecture
This isn't everything you need to now, it's what was assigned for reading/exercises. Make sure you cover all the topics above.
- Chapters 4-7
- Section 8.1
- Section 12.1
Assignment solutions
A2 solution [removed Sept 9 2016] (.zip, import to Eclipse or look at src folder)
A3 solution [removed Sept 9 2016] (.zip, import to Eclipse or look at src folder)
Midterm practice/reviews
These are from previous terms, but doing them is a good way to know what to expect on your midterm. Practice writing code by hand, as these questions were made for paper exams, and you won't have an IDE (eg. Eclipse) during the midterm.