Object-Oriented Programming
Classes and Objects
Access Specifiers and Encapsulation
Assignment
Bank Account with Controlled Access
Assignment
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.
Constructors and Garbage Collection
Assignment 1
Constructor Overloading Practice
Assignment 1
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 2
Garbage Collection
Learn about System.gc() and finalize().
"this" Pointer
Assignment
Practice "this" for Field and Constructor Disambiguation
Assignment
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.
Static Members
Assignment
Static Counter with Object Tracking
Assignment
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.