Postingan lainnya
object pada setiap bahasa pemrograman
Numpang nanyak gan, apa sih fungsi nya object dan penggunaannya dalam setiap bahasa pemrograman, maklum masik newbie
0
2 Jawaban:
Bahasa simpelnya, Object digunakan sebagai penggambaran/desain dari table database (atau sebaliknya) yang memiliki kolom/attribut2 untuk digunakan didalam aplikasi/program yang memakai object tersebut.
misal, object: Employee attribut: name, age, designation, salary
public class Employee {
String name;
int age;
String designation;
double salary;
// This is the constructor of the class Employee
public Employee(String name) {
this.name = name;
}
// Assign the age of the Employee to the variable age.
public void empAge(int empAge) {
age = empAge;
}
/* Assign the designation to the variable designation.*/
public void empDesignation(String empDesig) {
designation = empDesig;
}
/* Assign the salary to the variable salary.*/
public void empSalary(double empSalary) {
salary = empSalary;
}
/* Print the Employee details */
public void printEmployee() {
System.out.println("Name:"+ name );
System.out.println("Age:" + age );
System.out.println("Designation:" + designation );
System.out.println("Salary:" + salary);
}
}
\\ Object pada Java
1