GROUP NO : 2
MUHMMAD HUZAIFA
(CS32123205)
MUHAMMAD YOUNAS
(CS32232023)
MUHMAMAD HUZAIFA
(CS321232022)
MUNEEB –UDDIN
Introduction to Object Oriented Programing
Memory models
Memory models refer to the way a programming language
manages memory allocation, storage, and access in the
context of objects, variables, and their interactions.
Memory management is crucial in OOP because objects
need memory for both their data (fields or properties) and
behaviors (methods)
ASPECTS OF MEMORY MODELS IN OOPS
1. Stack memory
2. Heap memory
Stack Memory
Used for static memory allocation and managing function calls. Primitive
data types (like integers, floats) and references to objects are stored here.
Stack memory is limited in size and operates in a lastin, firstout (LIFO)
manner.
Heap Memory
Used for dynamic memory allocation, where objects are stored. Whenever
an object is created using new in languages like Java or C++, it is allocated
on the heap. Heap memory is larger than stack memory but also slower to
access because it requires more complex memory management (e.g.,
garbage collection)
Basic UML (Unified Modeling Language)
UML is a standard language for visualizing, specifying, and
documenting software systems. Basic UML elements include:
Class Diagrams: Representing classes, attributes,
methods, and relationships.
Objects: Represented by rectangles with attributes and
methods.
Attributes: Data members of a class (e.g., name, age).
Methods: Functions that operate on attributes (e.g.,
getName(), setName()).
Relationships: Association: Connection between
classes (e.g., Student Teacher).
Aggregation: Whole part relationship (e.g.,
University Faculty).
Inheritance:Generalization specialization
relationship (e.g., Animal Dog).
Composition: Strong containment relationship
(e.g., Car Engine).
A default constructor is a constructor that either has no
parameters, or if it has parameters, all the parameters have
default values. If there is no constructor in a class, compiler
automatically creates a default constructor.
:class MyClass {
public: MyClass() {} // Default constructor
};
DEFAULT CONSTRUCTOR
CONSTUCTOR OVERLOADING
if a class contain multiple constuctor where each type of
constuctor have different parameter list is called
constructor overloading.
SYNTAX
Class class –name {
Class –name()
{
}
Class –name(para1,para2)
{
}
};
Public class student {
int id;
String name;
Student (){
System.out.println(“this is a defult construct”);
}
Student(int i, string n){
id=i;
name=n;
}
public static void main (string [] args) {
//object creation
Student s1= new student();
Tudent s2= new student (10,” David”);

Introduction to Object Oriented Programing.pptx

  • 1.
    GROUP NO :2 MUHMMAD HUZAIFA (CS32123205) MUHAMMAD YOUNAS (CS32232023) MUHMAMAD HUZAIFA (CS321232022) MUNEEB –UDDIN
  • 2.
    Introduction to ObjectOriented Programing
  • 10.
    Memory models Memory modelsrefer to the way a programming language manages memory allocation, storage, and access in the context of objects, variables, and their interactions. Memory management is crucial in OOP because objects need memory for both their data (fields or properties) and behaviors (methods)
  • 11.
    ASPECTS OF MEMORYMODELS IN OOPS 1. Stack memory 2. Heap memory Stack Memory Used for static memory allocation and managing function calls. Primitive data types (like integers, floats) and references to objects are stored here. Stack memory is limited in size and operates in a lastin, firstout (LIFO) manner. Heap Memory Used for dynamic memory allocation, where objects are stored. Whenever an object is created using new in languages like Java or C++, it is allocated on the heap. Heap memory is larger than stack memory but also slower to access because it requires more complex memory management (e.g., garbage collection)
  • 12.
    Basic UML (UnifiedModeling Language) UML is a standard language for visualizing, specifying, and documenting software systems. Basic UML elements include: Class Diagrams: Representing classes, attributes, methods, and relationships. Objects: Represented by rectangles with attributes and methods. Attributes: Data members of a class (e.g., name, age). Methods: Functions that operate on attributes (e.g., getName(), setName()).
  • 13.
    Relationships: Association: Connectionbetween classes (e.g., Student Teacher). Aggregation: Whole part relationship (e.g., University Faculty). Inheritance:Generalization specialization relationship (e.g., Animal Dog). Composition: Strong containment relationship (e.g., Car Engine).
  • 14.
    A default constructoris a constructor that either has no parameters, or if it has parameters, all the parameters have default values. If there is no constructor in a class, compiler automatically creates a default constructor. :class MyClass { public: MyClass() {} // Default constructor }; DEFAULT CONSTRUCTOR
  • 15.
    CONSTUCTOR OVERLOADING if aclass contain multiple constuctor where each type of constuctor have different parameter list is called constructor overloading. SYNTAX Class class –name { Class –name() { } Class –name(para1,para2) { } };
  • 16.
    Public class student{ int id; String name; Student (){ System.out.println(“this is a defult construct”); } Student(int i, string n){ id=i; name=n; } public static void main (string [] args) { //object creation Student s1= new student(); Tudent s2= new student (10,” David”);