Devoir Libre N°1: Exercice I
Devoir Libre N°1: Exercice I
Exercice I :
Choisir 20 questions parmi la liste suivante puis les réaliser avec Java. Pour le choix des questions
vous devez obligatoirement suivre la méthode suivante :
Si dd/mm/yyyy votre date de naissance, on pose n = dd+mm
Si 41<= n <=43 répondre aux questions : n-1,n,n+1, n+2,.. ,n+18
Si 21<= n <=41 répondre aux questions : n-9,n-8,n-7,...n,n+1,n+2,...,n+10
Si 2<= n <=21 répondre aux questions : n, n+1,n+2,...+n+19
Répondre aux questions en français en expliquant d’abord votre méthode avant de donner le code
détaillé et commenté en Java. Justifiez vos choix si nécessaire.
Liste des questions :
2. How to find the missing number in integer array of 1 to 100?
3. How to find duplicate number on Integer array in Java?
4. How to initialize ArrayList with an array in Java?
5. How to reverse ArrayList in Java?
6. How to sort ArrayList in descending order in Java?
7. How to remove duplicates from array in place?
8. Print Matrix in Spiral form. (Given a Matrix(2D array), print it in spiral form.)
9. What’s the difference between array and linked list data structure?
10. How to check if array contains a number in Java?
11. How to find largest and smallest number in unsorted array?
12. There is an array with every element repeated twice except one. Find that element?
13. How to find k-th smallest element in unsorted array?
14. How to find common elements in three sorted array?
15. Rotate Matrix by 90 degrees clockwise Inplace. (Given N*M Matrix, Rotate it by 90 degrees Inplace.)
16. Print Matrix Diagonally OR Diagonal order of Matrix.
17. Search in a row wise and column wise sorted matrix.(Given an n x n matrix, where every row and column is
sorted in increasing order. Given a number k, how to decide whether this k is in the matrix. )
18. How to merge sorted array?
19. Write a program to find length of longest consecutive sequence in array of integers?
20. Transpose of Matrix Inplace. (You are given a M * N matrix, find Transpose of Matrix in-place.)
21. Find a Saddle point in Matrix. (Element is said to be Saddle point of Matrix if it is both a minimum of its
row and a maximum of its column or vice versa.)
22. How to rearrange array in alternating positive and negative number?
23. How to find if there is a sub array with sum equal to zero?
24. How to remove a given element from array in Java?
25. How to sort an array in place using QuickSort algorithm in Java?
26. Can you change size of Array in Java once created?
27. When to use ArrayList and LinkedList in Java?
28. How to loop over ArrayList in Java?
29. Difference between Vector and ArrayList in Java?
30. Difference between an array and ArrayList in Java?
31. How to check if array contains a duplicate number?
32. What are the different ways of copying an array into another array in Java?
33. Are Array thread safe in Java? If no give an example of code that can cause thread-safety issues
34. How to convert Array to LinkedList and vice-versa?
35. How to remove elements from LinkedList in Java?
36. How to merge integers of a sorted LinkedList and sorted ArrayList to form a sorted Array in Java?
37. How to initialize LinkedList with an array in Java?
38. How to get sublist from ArrayList in Java?
39. How to convert Array to ArrayList and vice-versa?
40. How to remove elements from ArrayList in Java?
41. Can you use Generics with Array in Java? Explain your answer by a piece of code
42. What is an anonymous array in Java? Give example?
43. Can you assign an Array of 100 elements to an array of 10 elements? Explain your answer by a piece of
code
44. How to reverse array in place in Java?
45. Do we have 3-dimensional arrays in Java? Explain your answer by a piece of code
46. Write a program to find intersection of two sorted arrays in Java?
47. Rotate Matrix by 90 degrees clockwise Inplace. (Given N*M Matrix, Rotate it by 90 degrees Inplace.)
48. Print Matrix in Spiral order using Recursion. (Given a Matrix(2D array), print it in spiral form
Recursively.)
49. How to find all pairs on integer array whose sum is equal to given number?
50. How to find repeated numbers in an array if it contains multiple duplicates?
51. Write a program to remove duplicates from array in Java?
52. How to find the smallest positive integer value that cannot be represented as sum of any subset of a given
array?
53. How do you check the equality of two arrays in java?
54. How to remove duplicates from ArrayList in Java?
55. How to synchronize ArrayList in Java?
56. How to reverse LinkedList in Java?
57. How to sort LinkedList in descending order in Java?
58. How to sort LinkedList in Java?
59. How to create and initialize ArrayList in one line?
60. How to sort ArrayList in Java?
61. How to convert ArrayList to String in Java?
Exercice II :
Ecrire une application Java pour la gestion des contacts ayant des fonctionnalités similaires à celle qui
se trouve sur votre Smartphone (ajouter, supprimer, modifier, rechercher, affecter à un groupe).
Un contact est caractérisé par : nom, organisation, type, numéro de téléphone et adresse email. Un
contact pourra être affecté à un groupe (Mes contacts, Familles, Amis, collègues,…), sinon il est classé
dans le groupe par défaut Mes contacts. L’application doit permettre de créer et de supprimer des
groupes. La suppression d’un groupe ne doit pas entrainer la suppression des contacts qu’il contient,
ces derniers doivent êtres plutôt placés dans le groupe par défaut.
Votre application doit avoir deux couches de d’accès aux données différentes :
1. Couche implémentée avec JDBC
2. Couche implémentée avec un ORM (Hibernate)
La conception de l’application doit permettre de passer d’une configuration ORM à JDBC sans
modification dans le code Java. Plus précisément, il faut qu’il soit possible de changer la couche
d’accès aux données utilisée par votre application en modifiant un seul paramètre dans un fichier texte
de configuration externe à l’application.
Utiliser une architecture en couches pour l’application (DAO / BLL / BO / GUI)
Utiliser le pattern DAO et Abstract Factory pour la conception des classes d’accès aux
données.
Utiliser l’injection de dépendance pour garantir une indépendance entre les couches de
l’application
Les règles de gestion doivent êtres implémentées dans la couche BLL.