Skip to content

A Java-based Quiz Application that allows users to take quizzes, track scores, and manage questions efficiently. The project demonstrates Core Java concepts, OOP principles, exception handling, JDBC connectivity with MySQL, and user session management. Built as a learning project, it highlights skills in Java programming, database integration.

Notifications You must be signed in to change notification settings

SidTirse-13/QUIZ_APP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎯 Quiz App (Java 17 + MySQL + JDBC)

A console-based Online Quiz Application built with plain Java (17), MySQL, and JDBC.
This repo provides user registration/login (passwords hashed with BCrypt), admin functionality to create/manage quizzes, and user flows to attempt quizzes and store results.

Overview

This application demonstrates a simple, modular approach to building a quiz system using JDBC for database interactions. The code is organized as services (UserService, QuizService, AdminService) and a console UI (Main.java). All persistent data is stored in a MySQL database.

Features

  • βœ… User registration and login (BCrypt hashed passwords)
  • βœ… Role-based behavior: ADMIN and USER
  • βœ… Admin can create quizzes and add questions
  • βœ… Users can list quizzes and attempt them
  • βœ… Results are stored in the database for later review

Prerequisites

  • Java 17 (JDK 17) installed and JAVA_HOME configured
  • Maven 3.6+
  • MySQL 8+ running locally (or reachable remotely)
  • Terminal or IDE (IntelliJ/Eclipse/VSCode)

Project structure

quiz-app/ │── src/main/java/com/quizapp/ β”‚ β”œβ”€β”€ DBConnection.java # Database connection β”‚ β”œβ”€β”€ UserService.java # Handles user login & registration β”‚ β”œβ”€β”€ QuizService.java # Handles quiz logic β”‚ β”œβ”€β”€ AdminService.java # Handles admin actions β”‚ β”œβ”€β”€ Main.java # Entry point (menu-driven application) β”‚ │── pom.xml # Maven dependencies & build

Database schema & sample data

Run these SQL commands in your MySQL client to create the database and tables used by the application.

#SQL

  1. Create database CREATE DATABASE quizdb CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; USE quizdb;

  2. Users CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(255) UNIQUE NOT NULL, password VARCHAR(255) NOT NULL, -- BCrypt hash (~60 chars) role ENUM('ADMIN','USER') NOT NULL DEFAULT 'USER', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );

  3. Quizzes CREATE TABLE quizzes ( id INT AUTO_INCREMENT PRIMARY KEY, title VARCHAR(255) NOT NULL, description TEXT, created_by INT, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );

  4. Questions (multiple choice stored in columns for simplicity) CREATE TABLE questions ( id INT AUTO_INCREMENT PRIMARY KEY, quiz_id INT NOT NULL, question_text TEXT NOT NULL, option_a VARCHAR(1024), option_b VARCHAR(1024), option_c VARCHAR(1024), option_d VARCHAR(1024), correct_option CHAR(1), -- 'A', 'B', 'C', 'D' FOREIGN KEY (quiz_id) REFERENCES quizzes(id) ON DELETE CASCADE );

  5. Results (attempts) CREATE TABLE results ( id INT AUTO_INCREMENT PRIMARY KEY, user_id INT, quiz_id INT, score INT, total INT, correct INT, time_taken_seconds INT, taken_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE SET NULL, FOREIGN KEY (quiz_id) REFERENCES quizzes(id) ON DELETE SET NULL );

πŸ›  Tech Stack

  • Java 17
  • MySQL 8+
  • JDBC (Java Database Connectivity)
  • Maven (dependency management & build tool)
  • BCrypt for password hashing

βš™οΈ Installation & Setup

1️⃣ Clone the Repository

[git clone https://github.com/SidTirse-13/QUIZ_APP
cd quiz-app

About

A Java-based Quiz Application that allows users to take quizzes, track scores, and manage questions efficiently. The project demonstrates Core Java concepts, OOP principles, exception handling, JDBC connectivity with MySQL, and user session management. Built as a learning project, it highlights skills in Java programming, database integration.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages