Summary

This document provides an introduction to Java programming, comparing object-oriented programming (OOP) concepts to procedural programming. It covers OOPS features like classes, objects, inheritance, polymorphism, encapsulation, and abstraction, highlighting their roles in programming paradigms. The document also explains programming paradigms and their benefits.

Full Transcript

# What is Java? - Java is a high-level, object-oriented programming language. - Java is platform-independent. - Java is mainly used for application programming. - It is widely used in: - Web applications - Mobile applications - Enterprise applications - Middleware applications # O...

# What is Java? - Java is a high-level, object-oriented programming language. - Java is platform-independent. - Java is mainly used for application programming. - It is widely used in: - Web applications - Mobile applications - Enterprise applications - Middleware applications # Object Oriented Programming vs. Procedural Programming | **Object Oriented Programming** | **Procedural Programming** | | --------------------------------- | ---------------------------- | | Bottom Up approach | Top Down Approach | | Divided into objects | Divided into functions | | Has Access Modifiers | Doesn't have Access Modifiers | | Objects can move & communicate with each other through member functions | Data can move freely from function to function in the system | | More secure | Less Secure | | Supports overloading | Do not support overloading | # Why We Need Programming Paradigms? "Any fool can write code that a computer can understand. Good programmers write code that humans can understand." - **Without understanding programming paradigms:** - Increase Complexity - Less Readability - Less Structure - Hard to Test - Hard to Change - Hard to Maintain # OOPS Features - Class - Object - Inheritance - Polymorphism - Encapsulation - Abstraction # Object Oriented Programming (OOPS) **Object-Oriented Programming** is a methodology or paradigm to design a program using **Classes and Objects**. - **Objects:** - Real world entities that has their own properties and behaviours. - **Example:** Class Dog - Properties: breed, size, age, color - Behaviour: eat(), sleep(), run(), bark() - **Classes:** - Blueprint from which an objects properties and behaviours are decided. # OOPS Concepts - **Object:** - Real World Entity - Properties - Tasks performed - Instance of class - Example: **Human** - Name - Color - Height - **Tasks:** walk(), run(), read(), write() - **Class:** - Blue Print that object follows - Number of objects - Example: **Student** - Properties: name, rollNo, DOJ - Tasks: read(), write(), play() - Objects: ABC, DEF, GHI - **Abstraction:** - Showing only Essential parts - Hiding the Implementation Details - **Example:** Android application - apk - exe - **Encapsulation:** - Binding Variables and Methods under single Entity - **Example:** - **Class:** - Name - Variables - Methods - **Student:** - name - rollNo - DOJ - **Tasks:** read(), write(), play() - **Inheritance:** - Acquiring the properties of one class to another class - **Super Class:** Parent Class - **Sub Class:** Child Class - **Base Class:** Derived Class - **Types of Inheritance:** - Single Inheritance - Multi-level Inheritance - Hierarchical Inheritance - **Polymorphism:** - Performing same Task in different ways & method - Example: - **drawPolygon()** - SQUARE - RECTANGLE - TRIANGLE - Types of Polymorphism: - **Method overloading:** Compile-time - **Method overriding:** Run-time

Use Quizgecko on...
Browser
Browser