Skip to main content

What it is? And How it/each of it works? ATTRIBUTE and CLASS of Determining "Specific" Functionality as it/each of it should be!

Attribute and Method of a Class in Object-Oriented Programming (OOP)

In Object-Oriented Programming (OOP), a class is a blueprint used to create objects. Inside a class, there are two important components: attributes and methods.


1. Attribute (Property / Field)

An attribute is a variable inside a class that stores the data or state of an object.

  • It represents what an object has.
  • Each object created from the class will have its own values for these attributes.

Example

Class: Car

Attributes:

  • brand
  • color
  • speed

Example in pseudocode:


class Car:

    brand = ""

    color = ""

    speed = 0

Explanation:

  • brand → stores the car brand (Toyota, Honda, etc.)
  • color → stores the color of the car
  • speed → stores the current speed

If an object is created:


myCar = Car()

myCar.brand = "Toyota"

myCar.color = "Red"

myCar.speed = 120

Here, brand, color, and speed are attributes.


2. Method (Function / Behavior)

A method is a function inside a class that defines the behavior or actions of the object.

  • It represents what an object can do.

Example


class Car:

    def start(self):

        print("Car is starting")

    def accelerate(self):

        print("Car is accelerating")

    def brake(self):

        print("Car is braking")

Explanation:

  • start() → action to start the car
  • accelerate() → action to increase speed
  • brake() → action to stop the car

Using the object:


myCar = Car()

myCar.start()

myCar.accelerate()

Here, start() and accelerate() are methods.


3. Simple Analogy

Example: Smartphone

Attributes (data):

  • brand
  • battery level
  • storage
  • screen size

Methods (actions):

  • turnOn()
  • turnOff()
  • call()
  • sendMessage()
Component Meaning Example
Attribute Data owned by object color, speed
Method Action performed by object start(), stop()

4. Short Definition

  • Attribute → variable that stores object data.
  • Method → function that defines object behavior.

Summary

In Object-Oriented Programming, a class contains:

  • Attributes → describe the state or data of objects
  • Methods → define the behavior or actions of objects

Objects created from the class use these attributes and methods.

Comments

Popular posts from this blog

[ERROR BUG]
ChatGPT+Gemini: TikTok → Blogger Embed Converter using Cloudflare/Online Server

🔄 Refresh Page ERROR BUG: The connection is blocked because it was initiated by a public page to connect to devices or servers on your local network. Planning: Revise Program CODE Code USING Javascript/Online Server Code NOT USING Javascript Sample Working Code aka Already Repaired! Temporary Solution is by Asking AI Assistant to do REPAIR CODE of (Not yet Repaired) Current Conversion Program Code-Output TikTok Archive – Embedded Preview TikTok Embed ▶ View this video on TikTok ⚠️ DISCLAIMER: INPUT URL LIMITATION This program is currently restricted to processing Full Browser URLs only. It does not support TikTok’s mobile "short-link" format (e.g., vt.tiktok.com ). Required Action: Users must open the video in a web browser and copy the expanded URL from the address bar before pasting it into this program. URL Conversion Example ❌ UNSUPPORTED: https://vt.tiktok.com/ZSaXoFyov/ ✅ REQ...

Repost! Web-Based to Android Apps Convertion (MEDIAN.CO etc.)

CONTOH HASIL Android APK "PROGRAM" SAMPLE: Youtube and Instagram EMBEDded to Blogger/Blogspot.com SOURCE CODE Click this box to download Contoh Sample SHORTCUT-APPs "precise" click to download : median.co R8: ronin1985.blogspot.com R2M: ronin-manu.blogspot.com Gw udah coba Median.co utk mengubah Website gw menjadi Aplikasi Android Keren bet!! Median.co Cekidot Software lain yg mirip! ChatGPT : If you're looking for tools similar to Median.co to convert websites into Android apps, here are some top alternatives, especially for no-code or low-code users: 🔧 Best Tools Like Median.co to Convert Website to Android Apps 1. WebViewGold Platform: Windows/macOS (Xcode/Android Studio) Key Feature: Converts any website into iOS/Android app via WebView. Pros: One-time purchase Custom splash screen, push notifications Can open external links in external browser Cons:  Requi...

REPOST: Studying WATER PUMP by ROMAN ENGINEERING

*^ Ini yg Asli Gan! Mekanisme pada Concrete Pump: Kok ky Sistem Mekanik Romawi ya?! Tapi malah bisa HANYA pake PER aka bukan "MATA BOR look a like" Mekanisme Drill yg Cost Pembuatan bikin REPOT aka harus Tool SUPER Khusus Dari Material Besi yg digunakan terlihat langsung secara kasat mata Jauh Lebih Banyak drpd Per Biasa seperti yg ditunjukkan pd Video Alternatif dgn Penggunaan PER Video dr Instagram: Source: YouTube Rome's drainage machines #history #romanempire #engineering