2. Overview of Java
• What is Java?
• - High-level, object-oriented programming
language.
• - Platform-independent (Write Once, Run
Anywhere).
• - Widely used in web, mobile, and enterprise
applications.
• Java Features:
3. Basic Java Concepts
• Java Syntax: Keywords, Identifiers, Data Types,
Variables, Operators.
• Control Structures: if-else, switch-case, loops
(for, while, do-while).
• Functions/Methods: Declaration, return types,
parameters.
• Example:
• public class HelloWorld {
4. Java Data Types
• Primitive: int, float, double, char, boolean.
• Non-Primitive: Arrays, Strings, Classes,
Interfaces.
• Type Conversion: Implicit and Explicit casting.
5. Control Flow in Java
• Conditional: if, else if, else, switch.
• Loops: for, while, do-while.
• Break and Continue statements.
6. Introduction to OOP
• What is OOP?
• - Programming paradigm based on objects.
• - Four Pillars: Encapsulation, Abstraction,
Inheritance, Polymorphism.
• Why Use OOP?
• - Code reusability
• - Easier maintenance
• - Logical structure
7. Encapsulation
• Real-World Example: Bank Account
• - Only methods like deposit/withdraw can
access balance.
• Code:
• class BankAccount {
• private double balance;
• public void deposit(double amount) { if
(amount > 0) balance += amount; }
8. Abstraction
• Real-World Example: Remote Control
• - Users interact with high-level operations
without knowing internal mechanics.
• Code:
• abstract class RemoteControl {
• abstract void turnOn();
• abstract void turnOff();
• }
9. Inheritance
• Real-World Example: Animal Kingdom
• - Dog and Cat inherit common behavior from
Animal.
• Code:
• class Animal { void eat()
{ System.out.println("Eating"); } }
• class Dog extends Animal { void bark()
{ System.out.println("Barking"); } }
10. Polymorphism
• Real-World Example: Payment Methods
• - Different payment types with same method
name `pay()`.
• Code:
• class Payment { void pay()
{ System.out.println("Processing..."); } }
• class CreditCardPayment extends Payment {
• void pay() { System.out.println("Credit
11. Java Classes and Objects
• Real-World Example: Car
• - Blueprint to create car objects with model
and year.
• Code:
• class Car {
• String model;
• int year;
• void displayInfo() {
12. Java Collections
• What are Collections?
• - Framework for storing and manipulating
groups of data.
• Types:
• - List (ArrayList, LinkedList)
• - Set (HashSet, TreeSet)
• - Map (HashMap, TreeMap)
• Example:
13. Conclusion
• Java Recap:
• - Versatile, object-oriented language.
• - OOP helps with modular, maintainable,
reusable code.
• - Java has strong community support.
• Thank you!