OOP Concepts - Part 02
- JAVA Language -
- In Java, an object can be generated only if there is a class.
- Only a class can be converted into an object.
Human h1 = new Human();
… h2 …
… h3 …
Type - 01
Type - 02
---------------------------------------------------------------------------------------------------------------------------
Primitive Data Types
đ
Types/formats used to hold data.
- Integer
- Float
- Binary (1/0)
1 byte - Integer
2. char - Integer
3. short - Integer
4. int - Integer
5. long - Integer
6. float - Floating Point
7. double - Floating Point
8. boolen - binary (true / false)
đ Integer Hierarchy,
1 long
2. int
3. short
4. char
5. byte
đ
Floating Hierarchy,
1 double
2. float
đĨ int a = 5; → Integer (any arithmetic expression)
long b = 7; → Integer
a + b; ✅
đĨ float c = 7.8; → float
double d = 9; → float
d - c; ✅
đĨ long e = 26467;
→ Various Types
float f = 789.54;
d - c; ❌
- The related primitive types can be accessed if they belong to the same type.
- If the types are different, it cannot be accessed directly.
String
- String is a class.
- Is a prebuilt (Unchangeable) class.
- Used as a Data Type.
- Not a primitive data type.
- Any data can be assigned from String.
Example :-
String s = "1273738638";
String s1 = "bddeuigbd";
String s2 = "#%^&$^**^$";
đĨ If a String Value is given, it must be given between two commas.
- See You in Part 3 -
đFollow Me :-
Blog :- devindawanasinghe.blogspot.com
Facebook :- devindawanasinghe.facebook.com
YouTube :- devindawanasinghe.youtube.com
Twitter :- devindawanasinghe.twitter.com
TikTok :- devindawanasinghe.tiktok.com
Comments
Post a Comment