Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

What is wrong with the following class design? import java.sql.Connection; impor

ID: 3830172 • Letter: W

Question

What is wrong with the following class design?

import java.sql.Connection;

import java.sql.SQLException;

import org.apache.commons.lang.StringUtils;

public class Employee {

private Integer id;

private String name;

private Connection con = null;

//getters and setters for above attributes go here.

public boolean validate() {

return id! = null && id > 0 && StringUtils.isNotBlank(name);

}

public void saveEmployee() throws SQLException {

//save Employee to database using SQL

//goes here...

}

publiv boolean validateEmployee() {

//logic to validate an employee

}

}

Explanation / Answer

import java.sql.Connection;

import java.sql.SQLException;

import org.apache.commons.lang.StringUtils;

public class Employee {

private Integer id;

private String name;

private Connection con = null;

//getters and setters for above attributes go here.

public boolean validate() {

return id! = null && id > 0 && StringUtils.isNotBlank(name);

}

public void saveEmployee() throws SQLException {

//saving the Employee details to the database using SQL

}

public boolean validateEmployee() {

// your logic to validate an employee

}

}

- only you were missing the public keyword in this statement i.e. publiv boolean validateEmployee() i correct that please try it.

Thanks...

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote