DEV Community

KIRUBAGARAN .K
KIRUBAGARAN .K

Posted on

Class and method

Today I learned class and method
How it's work with Example:

Your code defines a Bike class with attributes like name, model, milage, and cc. The getInformation() method prints out some of these attributes

class Bike{

String name;
int model;
int milage;
String cc;

public void getInformation(){
    System.out.println(name);
    System.out.println(model);
    System.out.println(milage);
    System.out.println(cc)

} 

 public static void main (String ar[]){

    Bike yamaha = new Bike();

    yamaha.name = "two wheeler";
    yamaha.model = 2023;
    yamaha.milage = 50;
    yamaha.cc = "200";

     yamaha.getInformation();



    }  


 }
Enter fullscreen mode Exit fullscreen mode

Top comments (1)

Collapse
 
manikandan_a8f99e0153ef77 profile image
MANIKANDAN

💥