Module 25: PACKAGES & ACCESS MODIFIERS
🎯 Beginner Friendly | VS Code + Pen Tab | Real-Life Focus
🎬 0:00 – 0:40 — REAL-LIFE STORY (Hook)
“Imagine you have a big wardrobe 👗👔.”
“All clothes are mixed together — shirts, pants, shoes, accessories 😵💫.”
“So you organize them:
🧺 One drawer for shirts
🧺 One drawer for pants
📦 One box for shoes
One shelf for accessories”
💡
“In Java, Packages do the same job — they organize code!”
ON-SCREEN TEXT
📌 Packages = Organize classes
🔒 Access Modifiers = Control visibility
🎬 0:41 – 1:20 — WHAT IS A PACKAGE?
“A package in Java is like a folder.”
“It groups related classes together.”
ON-SCREEN
✔ Makes code organized
✔ Avoids name conflicts
✔ Easy to manage large projects
“Examples you already use:
[Link] → Scanner, ArrayList
[Link] → File handling classes”
🎬 1:21 – 2:10 — CREATE & USE A PACKAGE (LIVE CODE)
“Let’s create our own package.”
VS CODE
// File: [Link]
package mypackage;
public class Greeting {
public void sayHello() {
[Link]("Hello from mypackage!");
}
}
“Now use it in another class.”
// File: [Link]
import [Link];
public class Main {
public static void main(String[] args) {
Greeting g = new Greeting();
[Link]();
}
}
“package defines the folder
import brings the class into your program.”
🎬 2:11 – 2:50 — WHY USE PACKAGES?
1️⃣Keeps project clean
2️⃣Avoids class name clash
3️⃣Improves reusability
📦 REAL-LIFE ANALOGY
Java Real Life
Packag
Drawer
e
Class Clothing item
Taking clothes
Import
out
🎬 2:51 – 3:30 — WHAT ARE ACCESS MODIFIERS?
“Access Modifiers decide who can access classes, methods, or variables.”
ON-SCREEN
✔ public
✔ private
✔ protected
✔ default
“Think of them as privacy settings 🔐.”
🎬 3:31 – 4:10 — ACCESS MODIFIERS TABLE
Modifi Accessible From
er
public Everywhere
private Same class only
protect Same package +
ed child
default Same package
“Each modifier gives a different level of access.”
🎬 4:11 – 4:50 — LIVE CODING (ACCESS MODIFIERS)
package mypackage;
public class Student {
public String name;
private int age;
protected String grade;
String school; // default
public void showDetails() {
[Link](name);
[Link](age);
[Link](grade);
[Link](school);
}
}
package mypackage;
public class Main {
public static void main(String[] args) {
Student s = new Student();
[Link] = "Aarya"; // public
// [Link] = 15; // private ❌
[Link] = "A"; // protected
[Link] = "ABC"; // default
[Link]();
}
}
“Private data stays hidden — just as it should.”
🎬 4:51 – 5:20 — REAL-LIFE ANALOGY (ACCESS MODIFIERS)
Modifi
Real Life
er
private ATM PIN
public Street sign
protect
Family album
ed
Roommate
default
items
“Privacy everywhere — even in Java!”
🎬 5:21 – 5:40 — MINI MISSION – PRACTICE
“Try this 👇”
1️⃣Create package school
2️⃣Create class Teacher
3️⃣Variables:
name → public
salary → private
subject → protected
school → default
4️⃣Access variables from same & different package
💡 Observe visibility changes.
🎬 5:41 – 6:00 — QUICK RECAP
✔ Packages organize classes
✔ Import connects packages
✔ Access modifiers control visibility
✔ private = most secure
✔ public = most open
🎬 6:01 – 6:20 — OUTRO
“Excellent work! 👏”
“You now understand how Java keeps code organized and secure.”
“Next module: Exception Handling — dealing with errors smartly 💥➡️😌.”
“Keep coding. Keep growing. 🚀”