Again n again@Joseinnewworld is back!
— Gaexe (@gaexe_) May 28, 2025
Thankyou for sweeping several of my #NFTs! 🙌
Your support means everything. Enjoy the perks, flex your collectible, and unlock the full Gaudio experience. 🎧💎 #eCash $XEC #BlockchainFuture #NFTdrop pic.twitter.com/k9alX2Szm1
To understand these 2 concepts, I assume that you have known or have played video games, whether it is a mobile game, console game, or PC game. Actually, the scope of this class and object is not limited to game software. But to make it easier to understand, I will take a game as an example.

Difference between Class and Object in OOP
Let's take the example of a Racing game. In a racing game, there must be various models and levels of cars. Well, the car is the CLASS, while the models such as lamborghini, toyota, sedan, audi, etc. are the OBJECTS. So you can conclude that CLASS is a kind of framework / structure / concept / prototype, while Object is the Model Variation.
Let's take another example of Humans, then Humans is the CLASS, while the OBJECTS can be Students, Pupils, Teachers, Lecturers, Doctors, Police, Pilots, etc.
CLASS is the basic structure of OOP. Consists of 2 members called attributes/properties and methods. Attributes/Properties define the specifications/completeness of the CLASS, while Methods define its nature/operations/how it works.
So, you can conclude again that an OBJECT is an instance of a CLASS.
To further strengthen your understanding of CLASS and OBJECT in the world of Object Oriented Programming, please pay close attention to the table below.
Example of the car class and its objects
Class
Class is the basic concept of object-oriented programming language, class is an abstract data type that describes a group of objects / properties / attributes. In the class consists of:
- Variables, variables in a class are better known as attributes or properties or objects.
- Function, known as method.
In Java, to create a class, based on the convention standards for naming classes, it must start with a capital letter, for example: Student (this is a class) Student (this is a variable or object)
Term
- Superclass -> parent class
- Subclass -> child class
Private Attribute Access
To access private attributes, just right click >> input code >> getter and setter. (using the Netbeans IDE application).
Inheritance
class A extends B {
//artinya apa yang ada di class A diturunkan ke class B
maka akan muncul pop up jika objek di panggil, dan apa yang ada di dalam pop up itu adalah atribut class simbah (A).
}Hope this is useful & happy learning!
Introduction to Classes and Objects
A class is a model of an object that contains information about the characteristics (data) and behavior of the object (methods), while an object is a manifestation of a class.
Class Declaration
To declare a class in Java is as follows:
<modifier> class <nama class>
[deklarasi atribut] [deklarasi method]
}Example:
public class Mahasiswa {
}A class consists of Attributes and methods. Attributes serve to record values, characters, and properties of a class. While methods are certain operations in a class.
Declaring Attributes and Methods
To declare an attribute use the following syntax:
<modifier> <tipe data> <nama atribut>Example:
public class Mahasiswa {
public String nama;
public String pt;
}Method declarations can use the following syntax:
<modifier> <return type> <nama method> ([daftar argument])
[statemen]
}Student Example.java
public class Mahasiswa {
public String nama;
public String pt;
public void aboutMe() {
System.out.println("Namaku " + this.nama);
System.out.println("Aku anak " + this.pt);
}
}Instantiating (creating) an Object
When we declare a class, it is only a blueprint or mold and not something we use. Imagine you want to build a house, then the class we define is only a plan. For that we have to realize it by making a real house according to the plan we made, so we can use it.
In this case we can instantiate (create) an object from the class we created. To create an object is as follows:
<nama class> <nama objek> = new <konstruktor class>Example of TestMahasiswa.java
public class TestMahasiswa {
public static void main(String[] args) {
Mahasiswa mhs = new Mahasiswa();
}
}Accessing Members (attributes, methods) of a class After you instantiate an object, you can access the members of the class as follows:
<nama objek> . <anggota>Example of TestMahasiswa.java
public class TestMahasiswa {
public static void main(String[] args) {
Mahasiswa mhs = new Mahasiswa();
mhs.pt = "STIMIK EL-Rahma Yogyakarta";
mhs.nama = "Irma Mutia Farisa";
mhs.aboutMe();
}
}Implement it into the program by creating a class named Mobil.java then complete the program as follows:
public class Mobil {
public String warna;
public String merek;
public void beliMobil(String warna, String merek) {
this.merek = warna;
this.warna = merek;
}
public void info() {
System.out.println("Aku punya mobil Keren"); System.out.println("Mereknya " + this.merek); System.out.println("Warnanya " + this.warna);
}
public void maju() {
System.out.println("Mobil Maju");
}
public void mundur() {
System.out.println("Mobil Mundur");
}
public void belok() {
System.out.println("Mobil belok");
}
public void berhenti() {
System.out.println("Mobil Berhenti");
}
}create a main class TestMobil.java as follows:
public class TestMobil {
public static void main(String[] args) {
Mobil myMobil = new Mobil();
myMobil.beliMobil("Biru", "Honda Jazz");
myMobil.info();
myMobil.maju();
myMobil.mundur();
myMobil.belok();
myMobil.berhenti();
}
}Run the program and observe the results. If there is still an error, read the error message and trace it. If the error persists, contact a doctor immediately
