Which of the following code will create/return a Locale object for the JVM, on which your code is running?
Given code of Test.java file:
1. package com.udayan.ocp;
2.
3. import java.util.List;
4. import java.util.Map;
5. import java.util.stream.Collectors;
6. import java.util.stream.Stream;
7.
8. class Certification {
9. String studId;
10. String test;
11. int marks;
12.
13. Certification(String studId, String test, int marks) {
14. this.studId = studId;
15. this.test = test;
16. this.marks = marks;
17. }
18.
19. public String toString() {
20. return "{" + studId + ", " + test + ", " + marks + "}";
21. }
22.
23. public String getStudId() {
24. return studId;
25. }
26.
27. public String getTest() {
28. return test;
29. }
30.
31. public int getMarks() {
32. return marks;
33. }
34. }
35.
36. public class Test {
37. public static void main(String[] args) {
38. Certification c1 = new Certification("S001", "OCA", 87);
39. Certification c2 = new Certification("S002", "OCA", 82);
40. Certification c3 = new Certification("S001", "OCP", 79);
41. Certification c4 = new Certification("S002", "OCP", 89);
42. Certification c5 = new Certification("S003", "OCA", 60);
43. Certification c6 = new Certification("S004", "OCA", 88);
44.
45. Stream
46. Map
47. stream.collect(Collectors.partitioningBy(s -> s.equals("OCA")));
48. System.out.println(map.get(true));
49. }
50. }
What will be the result of compiling and executing Test class?
Given code of Test.java file:
1. package com.udayan.ocp;
2.
3. import java.util.Arrays;
4. import java.util.Comparator;
5. import java.util.List;
6.
7. class Person {
8. private String firstName;
9. private String lastName;
10.
11. public Person(String firstName, String lastName) {
12. this.firstName = firstName;
13. this.lastName = lastName;
14. }
15.
16. public String getFirstName() {
17. return firstName;
18. }
19.
20. public String getLastName() {
21. return lastName;
22. }
23.
24. public String toString() {
25. return "{" + firstName + ", " + lastName + "}";
26. }
27. }
28.
29. public class Test {
30. public static void main(String[] args) {
31. List
32. new Person("Tom", "Riddle"),
33. new Person("Tom", "Hanks"),
34. new Person("Yusuf", "Pathan"));
35. list.stream().sorted(Comparator.comparing(Person::getFirstName).reversed()
36. .thenComparing(Person::getLastName)).forEach(System.out::println);
37. }
38. }
What will be the result of compiling and executing Test class?
© Copyrights Oracledumps 2025. All Rights Reserved
We use cookies to ensure that we give you the best experience on our website (Oracledumps). If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the Oracledumps.