OOP IN JAVA(OBJECT CREATION AND DATA TYPES)


Java is a oop concept based programmer language.Actually it's main strongest or most powerful part is OBJECT . Do you know whit is an object, object is a combination of Properties and behaviors.

Now,

How to creat OBJECT

Object Creation

In Java

The object is a foundation of an OOPs language,and  Java, we can't generate any program without creating an object. They are 2 different way to create an object in Java that we will discuss in this section, and also now I explain how to create an object in Java.

java, 4 points to create an object.


  1. Using class object name
  2. Using Variable
  3. Using new Keyword 
  4. Using clone() method.

 

 

And Mainly 2 different type to creat object in java


                   human cl = new Human ();

&

human cl;

cl= new human ();


Note : An object can be generated from java only if there is a class. Only a class can be converted to an object.


2 DATA TYPES 

Data Types in Java

 


Java main data type is a Primitive data types. It Contain 08 types in java , include byte ,char,short,int,long,float, double,boolean these all 08 types again dived 3 ways , 


  • Integer - byte/char/short/int/long
  • Floating point - float/double
  • Binary -boolean

And also integer and Floating contain hierarchy.


Note: If the relevant primitive data type is of the same type, it can be accessed. If the types are different, it cannot be accessed directly.

 Ex :

integer a= 2;

long l = 5;

a+l = 7

Float f= 7.8;

double d= 9;(9.0)

f-d;

long c= 346;

float g=345.8;

c+g ( Totally Wrong)

Now I move on explain of above 08 data types.

Data types specify the different sizes min and max values and Range that can be stored in the variable. There are,

Type

Size

Min values

Max value

Rang

Default Value

EX

Byte

8

-128

127

+127 to -127

0

byte b = 34;

Char

16

0

216-1

All uni Codes.

*/u0000*

char c = “ad34”

Short

16

-215

215-1

+32767 to -32767

0

short s =324;

Int

32

-231

231-1

A.N. N

0

int i=45678;

Long

64

-263

263-1

A.N. N

0L

long l =1234;

Float

32

-2149

(2-2).2-23127

A.N. N

0.0

float f= 456f

Double

64

-21074

(2-2).2-52 1023

A.N. N

0.0

double d= 23.4343

Boolean

1

 

 

T/F

False

Boolean b  = t/f

A.N.N- All Numeric Numbers


String. 

String is a class. It is called perbuild class. It is also used as a data type. It is a primitive data type. Finally, any data can be assed from string. Examples are as follows;


String s= "12456"

String s1="bacde"

String s2= "!@#$%"

String s3="hbi12%&"

 Note : The value should be put in the curly bracket


Thank you. 









Comments

Popular posts from this blog

DEMYSTIFYING THE POWER OF x86 ARCHITECTURE

A GUID TO BEACOMING A SOFTWARE ENGINEER

JAVA LAMBDA EXPRESSION