Loading...
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.
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.
Garbage Collection
Learn about System.gc() and finalize().
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 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.