Sie sind auf Seite 1von 7

DS 1.

Nome: ___________ Data: ___________

1. Write a simple code to solve the following problem: Given a group of letters, print all
existing acronyms. For example: {a,b,c} => abc; acb; bac; bca; cab; cba
DS 1.2

Nome: ___________ Data: ___________

2. When do you think it’s more appropriate to use JDBC instead of JPA?

3. Given the class “Parent” below, create a class “Child” that extends Parent, overrides
method “calcularMultiplicacao” and overloads method “concatenarFrases”.

public class Parent {

public String concatenarFrases(String f1, String f2){


return f1 + f2;
}

public int calcularMultiplicacao(int fator1, int fator2){


return fator1 * fator2;
}
}

4. Given the method below, explain:


public List<Alunos> readAlunos() {

Repositorio alunoRepository = new Repositorio();

try {
alunoRepository.setConnection(datasource.getConnection());
List<Alunos> listaAlunos = alunoRepository.readListaAlunos();
return listaAlunos;
} catch (Exception ex) {
throw new EJBException(ex);
} catch (SQLException ex) {
throw new DatabaseException(ex);
} finally {
alunoRepository.close();
}
}

a. Why is the close() method of class Repositorio being called inside finally?
DS 1.2

Nome: ___________ Data: ___________

b. The above code is wrong. What would you change in it to make it right? What other
improvements could you suggest to make it even better?

5. What will be the result of execution of the code below:


public class TesteFujitsu() {

public static void main(String[] args) {


int i = 2;

if (i++ <= 3 && ++i > 4)


i = 3;

System.out.println(i);
}
}

6. Considering the following example of the a4j:support usage, answer the below question:
DS 1.2

Nome: ___________ Data: ___________

<h:outputLink value="#">
<a4j:support reRender="component1, component2"
limitToList="true" event="onclick"
ajaxSingle="true
action="#{managedBean.method}">
</a4j:support>
</h:outputLink>

The a4j:support tag and its attributes are used to allow UI components to execute Ajax
actions. Describe a real situation when you would use this tag and explain why.

Salesperson Customer
ID Name Age Salary ID Name City Industry Type
1 Abe 61 140000 4 Samsonic Pleasant J
2 Bob 34 44000 6 Panasung Oaktown J
5 Chris 34 40000 7 Samony Jackson B
7 Dan 41 52000 9 Orange Jackson B
8 Ken 57 115000
11 Joe 38 38000
Orders
ID order_date customer_id salesperson_id Amount
10 8/2/96 4 2 540
20 1/30/99 4 8 1800
30 7/14/95 9 1 460
40 1/29/98 7 2 2400
50 2/3/98 6 7 600
60 3/2/98 6 7 720
70 5/6/98 9 7 150

7. Given the tables above, write the SQL query that returns:

a. The names of all salespeople that have an order with customers from Oaktown.

b. The names of all salespeople that don’t have any order with Samsonic.
DS 1.2

Nome: ___________ Data: ___________

c. The names of salespeople that have 2 or more orders.

d. Write an SQL statement to insert into a table called HighAchiever(Name, Age) all
salesperson that have a salary of 100000 or greater.

e. The total sales amount for each salesperson. If the salesperson hasn’t sold anything,
show zero.
DS 1.2

Nome: ___________ Data: ___________

8. The customer has the system called XYZ and he wants to start some updates that will be
split into 3 phases. The requirements for the first phase are the following:
 I want to start new data entries in the system (new
information that will be used in the 2nd phase)
 I want to include, update, delete and search plants (*)
 I want to include, update, delete and search sectors (*)
 I want to include, update, delete and search docks (*)
 Plants, sectors and docks need to have a code and a
description only
 The less the number of screens, the better
 The user interface needs to be easy to understand

* plants – client’s factories


* sectors – production lines’ sectors
* docks – places where the trucks are parked to be loaded

Based on the above information, which solution can you provide for the customer? Draw
a prototype (first draft to present to customer in order to validate your understanding).
DS 1.2

Nome: ___________ Data: ___________

9. Read the following description of a system functionality:

User Registration
- Screen where you can insert, delete or update user
information;
- User has properties “name”, “email”, “address” and
“phone”. Only the first two are mandatory;
- No user can have the same email;
- Only admin users can delete other users;

Describe which tests you would do to guarantee that everything is working correctly.
(For example: insert user with every property filled)

Das könnte Ihnen auch gefallen