0% found this document useful (0 votes)
7 views

Working With Object Data Types Java 2

Uploaded by

txicads144
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Working With Object Data Types Java 2

Uploaded by

txicads144
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Variables are memory locations reserved for storing values.

Size of the memory reserved depends on the data type.

Variables created must be mentioned of their data type.

Data types are the type of the data for which the memory will be allocated in the
variable.

There are two data types available in java


Primitive Data Types
Reference/Object Data Types.

Primitive data types are predefined in java.

They are named by a keyword(Built into java)

There are eight primitive data types in java.


They are:

byte float

short double

int boolean

long charr
----------------------------------------------------------------------
Reference data types are created using constructors of the classes.

They are nothing but creating object for a class.

There are three kinds of Variables in Java.


They are
Local Variables
Instance Variables
class/Static Variables

Local variables are declared in methods,constructors,or blocks.

They are visible only within the method or block it is decarled in.

Can't have default values,so value has to be assigned.

Instance variables are declared in a class,but outside a method,constructor or any


block.

So they are available for the entire class methods, constructors and blocks.

Instance varibles are created when an object is created for a class.

It is not necessary to initilize the instance variable.

Class/Static are declared in a class,but outside a method,constructor or any block


with a static keyword.

So they are available for the entire class methods,constructors and blocks.

Static variable or class variables are created when program starts and destroyed
when the program ends.

There will be only one copy of each class variables per class.

You might also like