You are on page 1of 4

JANN MARCUS M FLORES, IT21S2, 08 28 20

the object is called here by its reference variable


package oop;
class Employees {
String firstName;
String lastName;
String position;
char gender;
double salary;

void printDetails () { //method to print the Employee's details


System.out.println("Welcome, " +firstName+ " "+lastName);
System.out.println("Gender: "+gender);
System.out.println("You are assigned as our new "+position);
System.out.println("Your starting salary is Php "+salary);
}
}
public class Objects {
public static void main(String[] args) {//main method
Employees marcus = new Employees();
System.out.println("____________________________________________");
marcus.firstName = "Jann Marcus";
marcus.lastName = "Flores";
marcus.position = "Research Director";
marcus.gender = 'M';
marcus.salary = 35000.00;
marcus.printDetails();
System.out.println("_____________________________________________");
Employees naruto = new Employees();
naruto.firstName = "Naruto";
naruto.lastName = "Uzumaki";
naruto.position = "Hokage";
naruto.gender = 'M';
naruto.salary = 30000.00;
naruto.printDetails();
System.out.println("_____________________________________________");
}//end main
}//end class
the object here is called using constructors
package oop;
class Employees {
String firstName;
String lastName;String position;
char gender;
double salary;

void fillDetails(String fN, String lN, String p, char g, double s) {


firstName= fN;
lastName= lN;
position= p;
gender= g;
salary= s;
}
void printDetails () { //method to print the Employee's details
System.out.println("Welcome, "+firstName+ " "+lastName);
System.out.println("Gender: "+gender);
System.out.println("You are assigned as our new "+position);
System.out.println("Your starting salary is Php "+salary);}
}
public class Objects {
public static void main(String[] args) {//main method
Employees marcus= new Employees(); // object
marcus.fillDetails("Jann Marcus", "Flores", "Research Director", 'M',
35000.00);//String fN, String lN, String p, char g, double s
marcus.printDetails();//invokes the print details method
System.out.println();//space
Employees naruto= new Employees(); // object
naruto.fillDetails("Naruto", "Uzumaki", "Hokage", 'M', 50000.00); //String fN,
String lN, String p, char g, double s
naruto.printDetails();
}//end main
}//end class

You might also like