Skip to content

Latest commit

 

History

History

README.md

Packages & Interfaces

This section teaches you how to organize code using packages and how to work with interfaces to achieve abstraction.

Topics Covered:

  1. Packages - Grouping related classes together.
  2. Access Protection - How access modifiers affect package visibility.
  3. Interfaces - Defining contracts without implementation.

Example Programs:

  • PackageDemo.java - Show how to create and use a package.
  • StackInterface.java - Implement stack using an interface.

Exercises:

  1. Write a program showing the usage of a package.
  2. Write a program to implement a stack using an interface.

Now, move on to Exception Handling.


Files

  • TryCatchDemo.java: Demonstrates try, catch, throw, throws, and finally.
  • UserDefinedException.java: Demonstrates user-defined exceptions.
  • VoterAgeCheck.java: Throws exception if age is less than 18.
  • StackException.java: Throws exception if stack is full or empty.
  • BankBalanceException.java: Throws exception if bank balance drops below 1000.
  • SavingsAccount.java: Demonstrates exception handling in banking operations.