DEV Community

R.Shobika CSE
R.Shobika CSE

Posted on

JAVA- What is class?

OOPS:

  • OOPS - Object Oriented Programming Language

  • Java is a object oriented programming language

  • Java is simple and easy to understand

OOPS Concept:

  • Class

  • Object

  • Inheritance

  • Polymorphism

  • Abstraction

  • Encapsulation

Class:

  • Class is a blue print /template

  • Class is a container

  • Class is a collection of objects and methods

Class Home{
--------
--------
}
Enter fullscreen mode Exit fullscreen mode

Class name should start with upper case

class Home{
public static void main (String[] args){
System.out.println("HELLO WORLD!!!!");
}
}
Enter fullscreen mode Exit fullscreen mode

In the above program the classes are

  • Home

  • String

  • System

These three are the class in the above program because it start with uppercase

DATA TYPES IN JAVA:

  • In java Datatypes are divide into two
  1. Primitive datatype

  2. Non-Primitive datatype

Primitive datatype

  • byte->1byte=8bit

  • short->2byte

  • int->4byte

  • long->8byte

  • float->4byte

  • double->8byte

  • char->It store only one character

  • boolean->1 bit [true/false]

Non Primitive datatype:

  • String

  • class

  • array

class Home{
Static string name ="Shobi";
Static int addno=108;
//static keyword is used to store the class information is common for all and it take 1 memory space for whole class
public static void main(String[] args){
System.out.println(Home.name);
System.out.println(Home.age);
}
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)