class in java

class in java

Class

A class is a prototype witch is create objects in opps programming. A class is combination of related fields and methods. This fields are public, private, protected, and final. And methods are static or non-static and final. There are many type of classes

  • Concrete class
  • Abstract class
  • Final class

 Concrete class

A concrete class is basically public class because it’s easily access by another class.

Syntax.

 Class class-name{

  Access specifier datatype variable-name 1

  Access specifier datatype variable-name 2

  Access specifier datatype variable-name n

  Access specifier datatype method-name(){

}

}

 Final class

A final class is not extended class in oops programming. Because final is a non-access key word so can’t be extend the final class

Syntax.

 final class class-name{

  Access specifier datatype variable-name 1

  Access specifier datatype variable-name 2

  Access specifier datatype variable-name n

  Access specifier datatype method-name(){

}

}

Example of class

 Class ClassDemo{

  private float PI=3.14159;

  public void setPIValue(float fl)

{

 PI=fl;

}

public float getPIValue()

{

 return this.PI;

}

}


Ravi Vishwakarma

Ravi Vishwakarma

Hi, my self Ravi Vishwakarma. I have completed my studies at SPICBB Varanasi. now I am pursuing MCA final year from Veer Bahadur Singh Purvanchal University Jaunpur.

0 Comments

Leave Comment