Skip to content

Advanced Java programs demonstrating custom exception handling, arrays, HashMap operations, and stack implementation using collection classes. Includes solutions to five tasks with screenshots and detailed examples.

License

Notifications You must be signed in to change notification settings

TheComputationalCore/java-advanced-exceptions-collections

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

38 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Java Advanced: Exception Handling & Collections

Build Status License Java Repo Size


πŸš€ Overview

This repository contains advanced Java exercises (Q1–Q5) focusing on:

  • Custom Exception Handling
  • Input Validation
  • Java Collections Framework
  • HashMap operations
  • Stack implementation
  • User‑driven logic & error handling

All tasks include screenshots, organized source code, and a fully automated CI workflow.


πŸ“ Project Structure

java-advanced-exceptions-collections/
β”‚
β”œβ”€β”€ .github/workflows/
β”‚   └── java-build.yml
β”‚
β”œβ”€β”€ screenshots/
β”‚   β”œβ”€β”€ 1.a.png
β”‚   β”œβ”€β”€ 1.b.png
β”‚   β”œβ”€β”€ 1.c.png
β”‚   β”œβ”€β”€ 1.d.png
β”‚   β”œβ”€β”€ 2.a.png
β”‚   β”œβ”€β”€ 2.b.png
β”‚   β”œβ”€β”€ 3.a.png
β”‚   β”œβ”€β”€ 3.b.png
β”‚   β”œβ”€β”€ 3.c.png
β”‚   β”œβ”€β”€ 4.a.png
β”‚   β”œβ”€β”€ 4.b.png
β”‚   β”œβ”€β”€ 4.c.png
β”‚   β”œβ”€β”€ 4.d.png
β”‚   └── 5.png
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ AgeNotWithinRangeException.java
β”‚   β”œβ”€β”€ NameNotValidException.java
β”‚   β”œβ”€β”€ Student.java
β”‚   β”œβ”€β”€ Voter.java
β”‚   β”œβ”€β”€ QuestionThree.java
β”‚   β”œβ”€β”€ QuestionFour.java
β”‚   β”œβ”€β”€ QuestionFive.java
β”‚   └── (supporting logic)
β”‚
β”œβ”€β”€ LICENSE
└── README.md

🧠 Task Breakdown

Q1 β€” Student Class with Custom Exceptions

Validates:

  • Age must be between 15–21
  • Name must not contain numbers or special symbols

Uses two custom exceptions:

  • AgeNotWithinRangeException
  • NameNotValidException

Q2 β€” Voter Age Validation

Ensures:

  • Age β‰₯ 18
    Else throws Invalid Age Exception.

Q3 β€” Weekday Array Handling

  • Takes a day index as input
  • Prints weekday name
  • Handles:
    • Invalid numeric input
    • Array out‑of‑bounds cases

Q4 β€” Student Grades Using HashMap

Supports:

  • Add student + grade
  • Remove student
  • Fetch grade

Uses:

HashMap<String, Integer>

Q5 β€” Stack Implementation (Collections)

Operations:

  • push()
  • pop()
  • isEmpty()

Uses:

Stack<Integer>

πŸ–ΌοΈ Screenshots (Grid Layout)

Q1 β€” Student Management


Q2 β€” Voter Age Validation


Q3 β€” Weekday Array


Q4 β€” HashMap Grades


Q5 β€” Stack


▢️ How to Run

Clone

git clone https://github.com/TheComputationalCore/java-advanced-exceptions-collections.git

Navigate

cd java-advanced-exceptions-collections/src

Compile Everything

javac *.java

Run Any Task

java Student          # Q1
java Voter            # Q2
java QuestionThree    # Q3
java QuestionFour     # Q4
java QuestionFive     # Q5

πŸ“œ License

Distributed under the MIT License.


⭐ Contribution

Feel free to open PRs, file issues, or suggest improvements!

About

Advanced Java programs demonstrating custom exception handling, arrays, HashMap operations, and stack implementation using collection classes. Includes solutions to five tasks with screenshots and detailed examples.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages