Object Oriented Programming:
To Represent the real world into the computer for solving problems
To simulate the real world into the computer for solving problems
what is object?
- Object is real world entity.
- Combination of state & structure or property & behavior
- Property - Variables - used to identify
- Behavior - methods/functions - used by other object
- Object is an instance of a class.
How to create object:
- class name
- followed by object name
- equal to
- new keyword
- then constructor calling
This is a simple object++>
class A{
A a1=new A();
}
what is class?
collection of objectsCollection of state & behavior
it's a PLAN, BLUEPRINT, TEMPLATE
ex: Tree is class, inside the mangos are object.
Data Types:
Data types are useful to allocate memory for the data whatever I store.the computer memory is limited so we need use properly.
Primitive data - Fixed in size.
- byte - Stores whole number from (-128 to 127)
- Short - Stores whole number from (-36768 to 32767)
- int - Stores whole numbers from (-2,147,483,648 to 2,147,483,647)
- long - Stores whole numbers from (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)
- float - Stores fractional numbers (6 to 7 decimal digits)
- double - Stores fractional numbers (15 decimal digits)
- char - Stores single character/letter or ASCII values.
- Boolean - Stores true or false values
Non primitive data - variable in size (Array, string, class)
Access Specifiers:
- public - access anywhere
- private - access only within the class
- protected - access only child class
- default
Comments
Post a Comment