forked from Agrasha-Janarthanan/MyJobs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03.java.adv.practice.txt
129 lines (126 loc) · 5.96 KB
/
03.java.adv.practice.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
Collections
===========
- Streams (Refer to Person class here: \\nas\distribution\ref\java\tutorial\collections\streams\examples\Person.java)
1. filter
- predicates
- Write a program to filter the Person, who are male and age greater than 21
2. map
- Write a program to print minimal person with name and email address from the Person class using java.util.Stream<T>#map API
3. findFirst/last/any
- Write a program to filter the Person, who are male and
- find the first person from the filtered persons
- find the last person from the filtered persons
- find random person from the filtered persons
4. Sum/Max/Min
- Consider a following code snippet:
List<Integer> randomNumbers = Array.asList({1, 6, 10, 25, 78})
- Find the sum of all the numbers in the list using java.util.Stream API
- Find the maximum of all the numbers in the list using java.util.Stream API
- Find the minimum of all the numbers in the list using java.util.Stream API
5. Collectors
- Write a program to collect the minimal person with name and email address from the Person class using java.util.Stream<T>#map API as List
6. Reducer methods(ToInt, ToLong)
- Write a program to find the average age of all the Person in the person List
7. GroupBy, duplicate removal
- Consider a following code snippet:
List<Integer> randomNumbers = Array.asList({1, 6, 10, 1, 25, 78, 10, 25})
- Get the non-duplicate values from the above list using java.util.Stream API
8. forEach
- Print all the persons in the roster using java.util.Stream<T>#forEach
9. lambda
- sort the roster list based on the person's age in descending order using comparator
10. Iterator
- Iterate the roster list in Persons class and and print the person without using forLoop/Stream
11. Sorting
- sort the roster list based on the person's age in descending order using java.util.Stream
12. Addition/Update/Deletion of element to and from collections (addAll(), removeAll, add(), remove(), size())
- Consider the following code snippet:
List<Person> newRoster = new ArrayList<>();
newRoster.add(
new Person(
"John",
IsoChronology.INSTANCE.date(1980, 6, 20),
Person.Sex.MALE,
"[email protected]"));
newRoster.add(
new Person(
"Jade",
IsoChronology.INSTANCE.date(1990, 7, 15),
Person.Sex.FEMALE, "[email protected]"));
newRoster.add(
new Person(
"Donald",
IsoChronology.INSTANCE.date(1991, 8, 13),
Person.Sex.MALE, "[email protected]"));
newRoster.add(
new Person(
"Bob",
IsoChronology.INSTANCE.date(2000, 9, 12),
Person.Sex.MALE, "[email protected]"));
- Create the roster from the Person class and add each person in the newRoster to the existing list and print the new roster List.
- Print the number of persons in roster List after the above addition.
- Remove the all the person in the roster list
13. Contains
- Consider the following Person:
new Person(
"Bob",
IsoChronology.INSTANCE.date(2000, 9, 12),
Person.Sex.MALE, "[email protected]"));
- Check if the above person is in the roster list obtained from Person class.
14. retain() vs remove()
- Consider the following code snippet:
List<Person> newRoster = new ArrayList<>();
newRoster.add(
new Person(
"John",
IsoChronology.INSTANCE.date(1980, 6, 20),
Person.Sex.MALE,
"[email protected]"));
newRoster.add(
new Person(
"Jade",
IsoChronology.INSTANCE.date(1990, 7, 15),
Person.Sex.FEMALE, "[email protected]"));
newRoster.add(
new Person(
"Donald",
IsoChronology.INSTANCE.date(1991, 8, 13),
Person.Sex.MALE, "[email protected]"));
newRoster.add(
new Person(
"Bob",
IsoChronology.INSTANCE.date(2000, 9, 12),
Person.Sex.MALE, "[email protected]"));
- Remove the only person who are in the newRoster from the roster list.
- Remove the following person from the roster List:
new Person(
"Bob",
IsoChronology.INSTANCE.date(2000, 9, 12),
Person.Sex.MALE, "[email protected]"));
IO/NIO
======
1. Reading a file using InputStream
2. Reading a file using Reader
3. Read a any text file using BufferedReader and print the content of the file
4. Write some String content using OutputStream
5. Write some String content using Writer
6. Read a file using java.io.File
7. Read a file using java.nio.Files using Paths
8. Reading a CSV file using java.nio.Files API as List string with each row in CSV as a String
9. Given a path, check if path is file or directory
10. InputStream to String and vice versa
11. Object to inputStream and vice versa
12. Number of files in a directory and number of directories in a directory
13. Get the permission allowed for a file
14. Get the file names of all file with specific extension in a directory
15. Create two paths and test whether they represent same path
Properties
==========
1. Get and print a configurable property based on following priority:
- args passed for java cmd
- if not avaialble as cmd args, try to get from System env variables
- if not available from Sys Env, try to get from a customized .properties file (D:\temp\customize.properties)
- if not available in customized props files, get from a default .properties file (\\nas\Distribution\training\temp\default.properties)
- if not available in default props, load from a harcoded default constant
Try to use Properties.setParent() heirarchy mechanism to set out the priorities
2. Load and print localized greetings text based on a given Locale (in_en and in_ta)