DEV Community

vimala jeyakumar
vimala jeyakumar

Posted on • Edited on

object & class creation

Object creation:(Behavior)

Example:
public class Bank //Class Creation
{

public static void main(String[] args)
{
Bank manager = new Bank(); //Object Creation
//new allocates memory - Instance - Instantiation
manager.openAccount(); //Method Calling Statement
Bank cashier = new Bank();
cashier.deposit();

}

public void deposit() //Method Signature
{
//Method Definition / Body
System.out.println("Deposit amount in our Bank");
}

public void openAccount() //Method Signature
{
//Method Definition / Body
System.out.println("Opening Account in our Bank");
}

}

Output:
Opening account in our bank
deposit amount in our bank

Image description

Task:1
public class Mobile // create a class
{
public static void main (String[] args)
{
Mobile whatsapp = new Mobile();//instantiation
//new allocates memory
whatsapp.chat();//method calling statement
Mobile youtupe = new Mobile();
youtupe.watch_movie();
}

public void chat()//method signature
{
// method definition/body
System.out.println("sent a message in a group");
}
public void watch_movie()
{
System.out.println("i am watching movies in youtupe");
}
}

Output:
sent a message in a group
i am watching movies in youtupe

Image description

Task:2
public class Instagram
{
public static void main(String[] args)
{
Instagram message = new Instagram();
message.receive();
}
public void receive()
{
System.out.println(" I receive a message from my friend ");
}
}

Output:
I receive a message from my friend

Image description

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)