Final Exam: Thursday 12/14, 10:30am - 12:30pm

Project 6 is due on December 7

CS 152 - Computer Science II (Section 02)


Classes: TR 10:50am – 12:05pm, Maria Sanford Hall 221
Instructor: Dr. Zdravko Markov, 30307 Maria Sanford Hall, (860)-832-2711,, e-mail: markovz at ccsu dot edu
Office hours: MW 9:00am - 10:30am, TR 12:10pm - 2:00pm, or by appointment.

Catalog description: Computer Science II Prereq.: CS 151 and MATH 152. Further topics in object-oriented programming: inheritance, polymorphism, and Java interfaces. Event- driven programming. Elementary searching and sorting techniques. Recursion. Design with UML diagrams. Introduction to software engineering.

Prerequisites: CS 151 and MATH 152

Course Learning Outcomes:

Program Educational Objectives: CS 152 is part of the core CS program and is designed in accordance with the Program Educational Objectives and the Student Outcomes as specified in the Department Mission Statement. The course Learning Outcomes support the following Student Outcomes, wnich are part of the corresponding Program Educational Objectives:
  1. Graduates will have a broad understanding of the fundamental theories, concepts, and applications of computer science.
  2. Graduates will be prepared for careers in computer science and information technology.
Required textbook: Lewis & Loftus, Java Software Solutions: Foundations of Program Design, 8-th Edition, Addison-Wesley, 2015.

Required software: BlueJ - an integrated Java programming environment (

Class Participation: Regular attendance and active class participation is expected from all students. If you must miss a test, try to inform the instructor of this in advance.

Assignments and tests: Reading and problem assignments are listed under the schedule of classes. Some of the problems will be worked in class. There will be quizzes, two tests and a final exam. They will include material from the textbook, the lectures, and the programming projects.

Programming projects:  There will be 6 programming projects requiring the use of BlueJ to write and run Java programs. The projects with their due dates are listed below in the schedule of classes. All projects must be submitted through the class page in Blackboard Learn course management system at

Grading: The final grade will be based on projects (50%), quizzes (10%), tests (20%), and the final exam (20%), and will be affected by classroom participation, conduct and attendance. The letter grades will be calculated according to the following table:
A A- B+ B B- C+ C C- D+ D D- F
95-100 90-94 87-89 84-86 80-83 77-79 74-76 70-73 67-69 64-66 60-63 0-59

Unexcused late submission policy: Projects submitted more than two days after the due date will be graded one letter grade down. Projects submitted more than a week late will receive two letter grades down. No submissions will be accepted more than two weeks after the due date.

Honesty policy: The CCSU honor code for Academic Integrity is in effect in this class. It is expected that all students will conduct themselves in an honest manner and NEVER claim work which is not their own. Violating this policy will result in a substantial grade penalty, and may lead to expulsion from the University. You may find it online at Please read it carefully.

Students with disabilities: Students who believe they need course accommodations based on the impact of a disability, medical condition, or emergency should contact me privately to discuss their specific needs. I will need a copy of the accommodation letter from Student Disability Services in order to arrange class accommodations. Contact Student Disability Services, Willard Hall, 101-04 if you are not already registered with them. Student Disability Services maintains the confidential documentation of your disability and assists you in coordinating reasonable accommodations with your faculty.

Tentative schedule of classes, assignments, projects and tests (by week)

Note: Due dates for classes, assignments, and tests may change (see also University Calendar). Additional material may be posted. Check the schedule regularly for updates!
  1. Aug 29, 31, Sep 5, 7: Object Oriented Design and Arrays
  2. Sep 12, 14: Inheritance
  3. Sep 19, 21, 26: Polymorphism and sorting
  4. Sept 28: Searching
  5. Oct 3: Test #1 (Arrays, Inheritance, Visibility modifiers, Abstract classes, Polymorphism and Sorting, Chapters 8, 9, 10).
  6. Oct 5: Review of Test 1 and Chapters 8, 9, 10
  7. Oct 10: Introduction to Graphics
  8. Oct 12, 17: More Graphics
  9. Oct 19: GUI Design
  10. Oct 24: Polygons and polylines
  11. Oct 26, 31, Nov 2: Mouse and Key Events
  12. Nov 7: Adapter classes, event processing
  13. Nov 9: Test #2 (GUI applications)
  14. Nov 14: Exceptions
  15. Nov 21: Furlough day (No class)
  16. Nov 16, 28: Recursion
  17. Nov 30, Dec 5: Linked Lists
  18. Dec 7: Recursion in graphics
  19. Thursday 12/14, 10:30am - 12:30pm: Final Exam (includes all topics, textbook sections, and programs listed in the syllabus except for Graphics)

Programming Project 1

Log on to Blackboard Learn to see and submit the project.

Programming Project 2

Log on to Blackboard Learn to see and submit the project.

Programming Project 3

Log on to Blackboard Learn to see and submit the project.

Programming Project 4

Log on to Blackboard Learn to see and submit the project.

Programming Project 5

Log on to Blackboard Learn to see and submit the project.

Programming Project 6

Log on to Blackboard Learn to see and submit the project.

Test 1 Sample Problems

1) What does the following code do?  Assume list is an array of int values, temp is some previously initialized int value, and c is an int initialized to 0.
for (int j = 0; j < list.length; j++)
  if (list[j] < temp) c++;

a) It finds the smallest value and stores it in temp
b) It finds the largest value and stores it in temp
c) It counts the number of elements equal to the smallest value in list
d) It counts the number of elements in list that are less than temp
e) It sorts the values in list to be in ascending order

2) An int array stores the following values (in that order): 9, 4, 12, 2, 6, 8, 18

a) Demonstrate how the array is sorted in ascending order by the Selection sort algorithm. Show the content of the array after each pass of the outermost loop of the algorithm.
b) Demonstrate how the array is sorted in ascending order by the Insertion sort algorithm. Show the content of the array after each pass of the outermost loop of the algorithm.
3)  The code below adds elements to an array of objects Numbers and then prints the array. Add declarations for: Numbers, x, gen, and n, and define the class Num with the minimum information so that the code below runs. Hint: gen is an instance of the Random class.

      for (int i = 0; i < 10; i++)
       x = gen.nextInt(100);
       Num n = new Num (x);

     for (int index = 0; index < Numbers.size(); index++)
        System.out.println (Numbers.get(index));

4)  The following program generates a list of parts each one defined with a name and an ID. Then it finds the ID of the part named “Part 4” and prints its ID. Define the class Part accordingly. Hint: Part must implement the Comparable interface (defining properly compareTo) and should also include a constructor and a method toString().

public class Items
   public static void main (String[] args)
      Part [] list = new Part[6];
      Part target = new Part ("Part 4", 0);

      list[0] = new Part ("Part 1", 123);
      list[1] = new Part ("Part 2", 127);
      list[2] = new Part ("Part 3", 531);
      list[3] = new Part ("Part 4", 131);
      list[4] = new Part ("Part 5", 789);
      list[5] = new Part ("Part 6", 254);

      for (int i = 1; i < list.length; i++)
        if (list[i].compareTo(target) == 0)

5)  Consider the following partial class definitions:

  public class A
   public int x1;
   private int y1;
   protected int z1;

  public class B extends A
   public int x2;
   private int y2;
   protected int z2;

  public class C extends A
   public int x3;
   private int y3;

  public class D extends B
   public int x4;
   private int y4;

a) Draw a diagram showing the class hierarchy.
b) Explain the visibility (accessibility) of all variables.

Test 2 Review Topics

  1. GUI applications
  2. Polygons and polylines