Skip to main content
CMP175
Unit 3 of 8
6 Hours

Object-Oriented Programming

5 topics10 videos5 assignments
3.1

Classes and Objects

LecturePractical
3.2

Access Specifiers and Encapsulation

LecturePractical1 assignment

Assignment

Bank Account with Controlled Access

Assignment BriefDue: Complete before Topic 3.3 (Constructors and Garbage Collection)

Bank Account with Controlled Access

Build a BankAccount class where balance is private and can only be modified via deposit() and withdraw() methods. Prevent negative deposits and over-withdrawals with clear messages. Test at least five transactions and show final balance output.

3.3

Constructors and Garbage Collection

LecturePractical2 assignments

Assignment 1

Constructor Overloading Practice

Assignment BriefDue: Complete before Topic 3.4 ("this" Pointer)

Constructor Overloading Practice

Design a Book class with overloaded constructors: no arguments, title only, and title plus author plus price. Create objects using each constructor and print how object state changes based on constructor arguments.

Assignment 2

Garbage Collection

Assignment BriefDue: Complete before Topic 3.4 ("this" Pointer)

Garbage Collection

Learn about System.gc() and finalize().

3.4

"this" Pointer

LecturePractical1 assignment

Assignment

Practice "this" for Field and Constructor Disambiguation

Assignment BriefDue: Complete before Topic 3.5 (Static Members)

Practice "this" for Field and Constructor Disambiguation

Create a Student class where constructor parameters have the same names as instance variables, and use this to assign values correctly. Add a display() method and demonstrate object creation for at least three students with different data.

3.5

Static Members

LecturePractical1 assignment

Assignment

Static Counter with Object Tracking

Assignment BriefDue: Complete before Unit 4 (Inheritance and Polymorphism)

Static Counter with Object Tracking

Create an Employee class with instance fields (id, name) and a static field totalEmployees. Increment totalEmployees inside the constructor each time an object is created, and display both individual employee details and total employee count.