Sunday, 18 December 2022

Write a program to display name and age using class .

 

Write a program To display name  and age using class .



import java.util.*;

class Student {
    String name;
    int age;

    public void getInfo() {
        System.out.println(" Name is :=" + name);
        System.out.println("age is :=" + age);
    }

    public static void main(String args[]) {
        Student s = new Student();
        s.name = "avinash";
        s.age = 21;
        s.getInfo();

    }
}


No comments:

Post a Comment

GitHub Most Imp Command For Every Developer Learn:

 Top Command for GitHub:  1) git clone 2) git init and git status   3) git add file name  or git add .  4) git commit -m message  5) git rem...