SWT301_-_FA_2024_-_PE2_3061.webp
T

SWT301_-_FA_2024_-_PE2_3061.webp

Instructions:
SWT301 FALL24 - The final PE
Duration: 85 minutes
Proficiency in at least one programming language is necessary to perform adequately on certain exam questions.
Students may use IDEs like NetBeans, IntelliJ IDEA, or other similar software during the examination.
Students must submit their exam work in a single Word document; no other file formats will be accepted.
Question 1 (3 points):
The following Java class contains six defects related to code standards, logic, and best practices.
12345
public class EmployeeManager {
private List<String> EmployeeNames new ArrayList<>();
private Connection dbConnection;
public void ConnectToDatabase (String url) {
try {
dbConnection DriverManager.getConnection(url);if (dbConnection != null || url.isEmpty()) {
System.out.println("Connected to the database");
System.out.println("Error connecting to database: + e.getMessage());
public void addEmployee (String name) {
if (name.length() > 0) {
6
8
9
}
10
} catch (SQLException e) {
11
12
}
13
}
14
15
16
17
} else {
18
19
20
}
21
22
23
24
EmployeeNames.add(name);
return;
System.out.println("Employee name cannot be empty");
public void getAllEmployees () {
if (dbConnection == null) {
System.out.println("Database connection is not established");
Zoom
+ 100%
Close
Activate Wir
Go to Settings to

Thông tin

Category
SWT301
Thêm bởi
Thanh Vân
Ngày thêm
Lượt xem
4,261
Lượt bình luận
3
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
SWT301_-_FA_2024_-_PE2_3061.webp
File size
227.5 KB
Dimensions
1145px x 916px

Share this media

Back
Bên trên Bottom