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 Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more