Program Java untuk mencetak info siswa dengan menggunakan kelas, objek, metode.

class Student{
    String name;
    int age;

    public void printInfo(){
        System.out.println("This is my name: " + this.name);
        System.out.println("This is my age: " + this.age);
    }
}

public class OOP {
    public static void main(String[] args) {
        Student s1 = new Student();
        s1.name = "Syed Momin ALi";
        s1.age = 21;

        Student s2 = new Student(); // This is a new object
        s2.name = "Syed Khizar ALi"; 
        s2.age = 19; 

        s1.printInfo();
        s2.printInfo();
    }
}
M Faiz