plese help..what is the poblem about this codes?\

public abstract class Employee{
	private String firstName;
	private String lastName;
	private String socialSecurityNumber;
	public Employee(String first, String last, String ssn){
		firstName=first;
		lastName=last;
		socialSecurityNumber=ssn;
	}
	public void setFirstName(String first){
		firstName=first;
	}
	public String getFirstName(){
		return firstName;
	}
	public void setLastName(String last){
		lastName=last;
	}
	public String getLastName(){
		return lastName;
	}
	public void setSocialSecurityNumber(String ssn){
		socialSecurityNumber=ssn;
	}
	public String getSocialSecurityNumber(){
		return socialSecurityNumber;
	}
	public String toString(){
		return String.format(" %s %s \n social security number: %s ", getFirstName(), getLastName(), getSocialSecurityNumber());
	}
	public abstract double earnings();
}

Recommended Answers

All 2 Replies

Nothing... if you are wondering why you can't create an object from this code it's because you declared it as abstract. Otherwise it seems fine to me...

I think you need to rewrite your toString() method and kvass is right take the abstract off to your class otherwise everything is fine.
if i will rewrite it .. it will be

public class Employee{.....

public String toString(){
return String.format(" %s %s \n social security number: %s ", firstName, lastName, socialSecurityNumber);
}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.