Monday, May 3, 2021

CLASS AND VARIABLE (Experience In JAVA)

 EXPERIENCE IN JAVA (CLASS AND VARIABLE)

CLASS

class is a user-defined blueprint or prototype from which objects are created. It represents the set of properties or methods that are common to all objects of one type.

Syntax of class:

          class ClassName{

            ......................

}

  1. Data Member ( Variable )
  2. Member function(  function )

Driver Function "main()"

It is a user defines a function that controls the execution of the program. It is also known as driver function.

The execution of the program is started and ended at the main function.

The basic syntax of main()

          Public static void main(String pk[])

          {

………………..

……………….

}

Output

Now we have discussed the output screen, which class and method are responsible to display program output.

println() – it is a predefined function that is responsible to display messages and values in the output screen.


VARIABLE


  1. Name --: Valid Identifier 
  2. Typer of Data Type --: 1. Type of value, 2. Value range, 3.Set if Operation
  3. Value --: Initialization (int a=20;), Through Comment line argument, Through Scanner Class, Through InputStreamReader, Through DataInputStream, Garbage

There are five types of variable in java.

  1. Local Variable 
  2. Instance Variable 
  3. Static Variable
  4. Final Variable 
  5. Block Variable
GLOBAL variable one more variable but in java not declared.

The scope is the area from which a variable maybe access. It totally depends on how and where the variable declared.

LOCAL VARIABLE

The variable which is declared inside of a function is known as a local variable.The scope of local variable is within that function in which variable is declared

INSTANCE VARIABLE

The variable which is declared in-side of the class but outside of all the member function of the class is known as instance variable, it is known as data member of the class.

STATIC VARIABLE 

Static variable is a special type of Instance variable which value is common all the object of the class. It can be only access by static member function of the class to declare in static variable we have to use static keyword into variable declaration.

FINAL VARIABLE 

It is special type of variable which value cannot be change during execution of the program. To make a variable final we have to use final keyword before variable before variable declaration.

It is use to constant in java

BLOACK VARIAVLE

The variable which is declared in side of a block is known as block variable. The scope of block variable is within that block only. 

*GLOBAL VARIABLE *       

The variable which is declared outside of class is known as the global variable. It is not possible in java. 



No comments:

INTRODUCTION TO COMPUTER NETWORKS

A Computer network consists of two or more autonomous computers that are linked (connected) together in order to: • Share resources (files...