DEV Community

Cover image for DAY 1(22:5:25)
Vignesh . M
Vignesh . M

Posted on • Edited on

DAY 1(22:5:25)

On the first day at Payilagam Institute, the participants were greeted with a warm and friendly atmosphere.As they settled in, the trainer, prithiviraj, began the session by discussing the class and object. first question we dicussing
//what is class?
Class is a collection of object
*It doesn't take a any space on memory
*Class also called a blueprint
*If create a class name it's start from upper case only
ex:
what is blueprint?
A single sheet of the plan to build n-number of construction.so a single class can create a n-number of methods and veriable depends on the class
//Second Topic OBJECT
//what is Object?
*Object is a instance of Class
*If creating a object name state only lower case only
*Each class having a Own state and behavior
*A class is a blueprint for creating objects in object-oriented programming.
*
State:*
* State is a variable that holds information about an object in object-oriented programming.
*It represents a specific condition or value of that object at a particular time

  *Example (Car):

      In the real world, there are many cars, but each car belongs to a specific company like TATA, HONDA, or BMW. These company names represent the state of a car object. So, if a car object has the company name "BMW", then "BMW" is the state of that object.
Enter fullscreen mode Exit fullscreen mode

*Behavior:
*It is action-oriented.
*It depends on the current state or context.
*Behaviors can change when the state or environment changes.

Example (Car):
*A Honda car has a behavior like:

 *Speeding up when you press the accelerator

 *Slowing down when you press the brake

 *The maximum speed it can reach is part of its behavior
Enter fullscreen mode Exit fullscreen mode

SAMPLE PROGRAM:

public class Calse // class name
{
public static void main(String args[])// main method
{
System.out.println("calculater");//print statement
}
}

OUTPUT:Calculater

CALCULATER PROGRAM:

public class Calse //class name
{
public int add(){ //veriable diclaration
int a=5,b=6;
System.out.println("a= 5 b= 6 = "+(a+b)); // printing statement
return 5+6; // return statement
}
public int sub(){
int a=8,b=5;
System.out.println("a= 8 b= 5 = "+(a-b));
return 8-5;
}
public static void main(String args[]){ // main method
Calse calse = new Calse();//object creation
int addition = calse.add();//call the object
int subration = calse.sub();
int multipication= addition * subration; //method
int divition = addition / subration;
System.out.println("add * sub = :" +multipication);
System.out.println("add / sub = :" +divition);
}
}

output:

Image description

Top comments (2)

Collapse
 
prithivi_raj_99b857c5e4cd profile image
prithivi raj

Nice Effort, keep updating the blog regularly...