JAVA FUNDAMENTAL

JAVA FUNDAMENTAL









Class -

A class can be defined as a template/blueprint that describes the behavior/state that the object of its type support. class is logical entity.

Object 

Objects have states and behaviors. Example: A dog has states - color, name, breed as well as behaviors – wagging the tail, barking, eating. An object is an instance of a class.
it can be logical or physical entity.



1) In Java some words are reserved to represent some meaning and functionality such type of words called reserved word.



2) 
    -  Java is not considered as pure object oriented language because several oops concept are not           satisfied by java like operator overloading and multiple inheritance 
    - We are depending on primitive data types ,which are non-objects.


in below table shows data type with their default data and size of data type ...
                             
1 byte = 8 bits.


  • char - 2 byte
  • byte -  1 byte
  • short - 2 byte
  • Int - 4 byte
  • long - 8 byte
  • float - 4 byte.
  • double - 8 byte.

literal -

int x = 10;

A constant value which can be assign to the variable is called a literal.



Arrays -

Array is an indexed collection of fixed length of homogeneous data element.


Type of variables - All variable are divided into two types

1] Primitive variable

eg - int , float , long

2] Reference variable 

eg - class , interface.


3 types of variable -

1] instance 

A variable declared inside the class but outside the body of the method, is called instance variable. It is not declared as static.

It is called instance variable because its value is instance specific and is not shared among instances.


2] static

A variable which is declared as static is called static variable. It cannot be local. You can create a single copy of static variable and share among all the instances of the class. Memory allocation for static variable happens only once when the class is loaded in the memory.

 

3] local 

A variable declared inside the body of the method is called local variable. You can use this variable only within that method and the other methods in the class aren't even aware that the variable exists.

A local variable cannot be defined with "static" keyword.































Comments

Popular posts from this blog

OBJECT ORIENTED CONCEPTS

Arrays programms