Você está na página 1de 4

The following are questions designed to test your familiarity with our technologies and

examine your coding style and process. Several parts of these questions are intentionally
vague and you should explain any assumptions you make in order to solve these problems.

Question 1: SQL

Design two SQL tables. One should hold company information, including its name, and
the other should include employee information, including the employee's name, status
and which company he works for. Provide the SQL to create these tables.

ANSWER:
CREATE TABLE company_info (
company_id bigint(20) NOT NULL AUTO_INCREMENT,
company_name varchar(20) NOT NULL,
company_info varchar(20) NOT NULL,
PRIMARY KEY (company_id)
)

CREATE TABLE employee_info (


employee_id bigint(20) NOT NULL AUTO_INCREMENT,
name varchar(20) NOT NULL,
status int(11) NOT NULL,
company_id bigint(20) NOT NULL,
PRIMARY KEY (employee_id),
KEY fk1 (company_id),
CONSTRAINT fk1 FOREIGN KEY (company_id) REFERENCES company_info (company_id)
)

If necessary, alter your tables so that employee names can be printed as "Lastname,
Firstname" as well as "Firstname Middlename Lastname Suffix."

ANSWER:
ALTER TABLE employee_info
DROP FOREIGN KEY fk1,
CHANGE name first_name VARCHAR(20) NOT NULL,
ADD last_name VARCHAR(20) NOT NULL AFTER name,
ADD middle_name VARCHAR(20),
ADD suffix VARCHAR(20);

ALTER TABLE employee_info


ADD CONSTRAINT fk1 FOREIGN KEY (company_id) REFERENCES company_info
(company_id);

Write an SQL query that would retrieve all the companies who have inactive
employees. (Inactive employees will have status == 2)

ANSWER:
select c.company_name from company_info c,employee_info e where
c.company_id=e.company_id and e.status=2;

Create a query to get all inactive employees. Retrieve the following information: the
resource name and the employee's name in "Lastname, Firstname" format.
select concat(e.last_name," ",e.first_name) as name from company_info
c,employee_info e where c.company_id=e.company_id and e.status=2;
RETURN return_value;

Bonus: Assume you are using MySQL 5. Create maintainable stored proceedures for
both of the above.

Connection con = null;


CallableStatement proc_stmt = null;
ResultSet rs = null;

try {

Class.forName("com.mysql..jdbc.Driver");

con =
DriverManager.getConnection("jdbc:sqlserver://MYSERVER;databaseName=raviteja",
"root", "pichilan");

proc_stmt = con.prepareCall("{ call getInactiveCompanies (?) }");

proc_stmt.setInt(2, "status");
rs = proc_stmt.executeQuery();

if (rs.next()) {
String companyName = rs.getString(2);
System.out.println("Inactive Companies: " + companyName );
} else {
System.out.println("Stored procedure couldn't get company Name");
}
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} catch (SQLException ex) {
ex.printStackTrace();
} finally {

try {

rs.close();
proc_stmt.close();
con.close();

} catch (SQLException ex) {


ex.printStackTrace();
}
}

CREATE FUNCTION getInactiveCompanies (status integer) RETURNS company_name


varchar;
BEGIN
select c.company_name from company_info c,employee_info e where
c.company_id=e.company_id and e.status=2;
RETURN return_value;
END

Bonus: Explain how you would optimize any of the above. What information would you
need?

Question 2: JAVA
Design Java classes that would represent the above tables.
Zipped files attached

Design Database Access Object (DAO) that utilizes the queries you wrote on question
1.

Zipped files attached


Add functionality to your classes that allows the user to retrieve the employee's name
in either "Lastname, Firstname" or "Firstname Middlename Lastname Suffix"

ZIPPED FILES ATTACHED


Bonus: Suggest two different frameworks to make these classes persistent. Evaluate
the pros and cons of each framework.
ANSWER:
HIBERNATE AND EJB

Bonus: Adapt your objects to each of the two frameworks you suggested. Use the
examples to explain your previous suggestions.

Question 3: Web Application


Using your prefered java based web application framework, design a user interface
that does the following:
Presents the list of companies with inactive employees.
Users should be able to select a specific company, which would take them to
another page, listing the specific employees who are inactive
ZIPPED FILES ATTACHED

Bonus: Utilizing the J2EE6 stack, design the above interface again. Evaluate the pros
and cons of this solution compared to yours. (If your preferred framework is J2EE6,
pick another framework and do the same with it.)

Question 4: General Development


What development tools do you prefer for doing web application work? What is
particularly cool about them? What are their limitations?
Eclipse Winsep Editplus Toad.

What java technologies are your particularly excited about? These do not need to be
web specific technologies.

What java technologies have you used that you dislike? What did you dislike about
them? What would you use instead? These do not need to be web specific
technologies.

Swings, Applets. I prefer

Question 5: Networking
What are two types of files systems used in Linux?
ext2, ext3

What is a good secure and easy to maintain OS for a network server? What do you like
best about it?

What are the different ways to configure a Cisco router?


For a production level server, what kind of hardware would you want on it and why?

Você também pode gostar