Obiekt
Obiekt to instancja klasy, która zawiera rzeczywiste wartości atrybutów i może wykonywać metody zdefiniowane w swojej klasie.
Types: 1. Remote code execution. 2. Privilege escalation. 3. Denial of Service (DoS). Phases: 1. Reconnaissance. 2. Triggering vulnerability. 3. Payload delivery.
graph LR
Center["Obiekt"]:::main
Pre_class["class"]:::pre --> Center
click Pre_class "/terms/class"
Rel_class["class"]:::related -.-> Center
click Rel_class "/terms/class"
Rel_graph_data_structure["graph-data-structure"]:::related -.-> Center
click Rel_graph_data_structure "/terms/graph-data-structure"
Rel_hash_table["hash-table"]:::related -.-> Center
click Rel_hash_table "/terms/hash-table"
classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
linkStyle default stroke:#4b5563,stroke-width:2px;
🧒 Wyjaśnij jak 5-latkowi
Jeśli klasa to foremka do ciastek (kształt), to obiekt jest rzeczywistym ciastkiem! Każde ciastko (obiekt) ma swoje własne kawałki czekolady i lukier (dane), mimo że wszystkie pochodzą z tej samej foremki (klasy).
🤓 Expert Deep Dive
Tożsamość obiektu vs równość: '==' testuje tożsamość, '.equals()' testuje równość wartości. Pula obiektów (Object Pooling) ponownie wykorzystuje instancje, aby uniknąć narzutu alokacji. Obiekty internowane (ciągi znaków, małe liczby całkowite) współdzielą pojedynczą instancję. OOP oparte na prototypach (JavaScript) tworzy obiekty z innych obiektów bez klas. Refleksja umożliwia inspekcję obiektów w czasie wykonywania. Serializacja konwertuje obiekty na strumienie bajtów.