OOP Concepts - Part 02

 

 - JAVA  Language -






  Object Creation




  • 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.


Data Types Chart
                                                Show Full Screen



   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 -




Comments

Popular posts from this blog

OOP Concepts - Part 01

Method Overriding & Super Keyword (OOPC - Part 07)

Inheritance (OOPC - Part 06)

If You Can Gain Even A Little Bit Of Knowledge From This, That Is My Happiness.

Parameters & Arguments (OOPC - Part 03)

Method Overloading (OOPC - Part 05)

Constructor (OOPC - Part 04)