New Semester
Started
Get
50% OFF
Study Help!
--h --m --s
Claim Now
Question Answers
Textbooks
Find textbooks, questions and answers
Oops, something went wrong!
Change your search query and then try again
S
Books
FREE
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Tutors
Online Tutors
Find a Tutor
Hire a Tutor
Become a Tutor
AI Tutor
AI Study Planner
NEW
Sell Books
Search
Search
Sign In
Register
study help
computer science
oracle
OCP Oracle Certified Professional Java SE 11 Developer Practice Tests Exam 1Z0 819 And Upgrade Exam 1Z0 817 1st Edition Scott Selikoff, Jeanne Boyarsky - Solutions
Which statements about parallel streams are correct? (Choose two.)A. A parallel stream is always faster than a serial stream.B. The JVM will automatically apply a parallel stream operation to an arbitrary stream in order to boost performance.C. A parallel stream synchronizes its operations so
What is the output of the following? A. over the riverB. through the woodsC. to grandmother's house we goD. None of the above. var s = Stream.of ("over the river", "through the woods", "to grandmother's house we go"); s.filter (n => n.startsWith ("t")) .sorted (Comparator::reverseOrder)
Which can fill in the blank to have the code print the single digit 9? A. Only mapToDoubleB. Only mapToIntC. Only mapToLongD. Both mapToDouble and mapToIntE. mapToDouble, mapToInt, and mapToLongF. None of the above. var stream LongStream.of (9); stream.. = (p> p). for Each
What is the output of the following application? A. 100B. 200C. 250D. The code does not compile because of line j1.E. None of the above. package savings; import java.util. function. *; public class Bank { private int savingsInCents; private static class ConvertToCents { static
Which statements about stateful lambda expressions are correct? (Choose two.)A. Stateful lambda expressions should be avoided on both serial and parallel streams.B. Stateful lambda expressions should be avoided on only serial streams.C. Stateful lambda expressions should be avoided on only
Which method reference can replace the lambda on the second line so the output is the same? A. a::contains(b)B. a::containsC. String::contains(b)D. String::containsE. The supplied code does not compile.F. None of the above. var s = "fish"; Predicate pred System.out.println(pred.test("fish",
What is the best example of lazy evaluation?A. The pipeline can execute before seeing all the data.B. The pipeline does not begin until the terminal operation is executed.C. The pipeline executes all operations as quickly as possible.D. The pipeline loses data.E. The pipeline takes a nap.
Which method can be applied to an existing Stream to return a stream with a different generic type?A. distinct()B. iterate()C. peek()D. sorted()E. filter()F. None of the above.
The ______________ functional interface has an apply() method, while the ______________ functional interface has an applyAsDouble() method. (Choose two.)A. BiConsumerB. BiFunctionC. BiPredicateD. DoubleConsumerE. DoublePredicateF. DoubleUnaryOperator.
Given the following code snippet, what statement about the values printed on lines q1 and q2 is correct? A. They are always the same.B. They are sometimes the same.C. They are never the same.D. The code does not compile.E. The code will produce a ConcurrentModificationException at
Which of the following can fill in the blank to have the code print out *? A. (s,t) -> s.length() - t.length()B. String::isEmptyC. Both of these will produce the desired output.D. Neither of these will allow the code to compile.E. The code does not complete regardless of what goes in the
Which statement about functional interfaces and lambda expressions is not true?A. A lambda expression may be compatible with multiple functional interfaces.B. A lambda expression must be assigned to a functional interface when it is declared.C. A method can return a lambda expression in the form
Which can fill in the blank to have the code print true? A. anyMatchB. allMatchC. noneMatch.D. None of the above. var stream Stream.iterate(1, var b = stream.. System.out.println(b); i-> i); (i -> i> 5);
Given the following class, how many lines contain compilation errors? A. None. The code compiles as is.B. One.C. Two.D. Three.E. Four.F. Five. 1: package showtimes; 2: import java.util.*; 3: import java.util. function. *; 4: public class FindMovie { 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
Which statements about the findFirst() method applied to a stream are correct?(Choose three.)A. It always returns the first element on an ordered serial stream.B. It may return any element on an ordered serial stream.C. It always returns the first element on an unordered stream.D. It may return
Which method reference can replace the lambda in the first line of the main() method to produce the same output? A. System:out:printlnB. System::out:printlnC. System::out::printlnD. System.out::printlnE. None of the above. interface Marsupial { void carryInPouch (int size); } public class
What is true of the following code? A. The code runs without error and prints 0.B. The code runs without error and prints 1.C. The code throws an exception on line 23.D. The code throws an exception on line 24.E. The code throws an exception on line 25.F. The code throws an exception on line
Which changes can be independently made to this code and have it still compile? (Choose three.) A. Change StringBuilder b to var b.B. Change StringBuilder b to b.C. Remove StringBuilder b.D. Remove ->.E. Remove { and ;}.F. Remove { return and ;}. Predicate p = (StringBuilder b) -> {return
What does this code output? A. babyB. chickC. cygnetD. ducklingE. The code does not compile. var babies = Arrays.asList("chick", "cygnet", "duckling"); "baby"; babies.replaceAll(x -> { var newValue return newValue; }); System.out.println(newValue); =
Which lambda expression cannot be assigned to a DoubleToLongFunction functional interface? A. a -> null==null ? 1 : 2LB. e -> (int)(10.0*e)C. (double m) -> {long p = (long)m; return p;}D. (Double s) -> s.longValue()E. All of these can be assigned.
Given the following code snippet, which values of x will allow the call divide(x) to compile and provide predictable results at runtime? (Choose
Which of the following produces different output than the others? A. Stream.of ("eeny", "meeny", "miny", "moe") .collect (partitioningBy (x -> x.charAt(0) .get(false) B. C. .stream ( ) .collect (groupingBy (String:: length)) .get(4) Stream.of("eeny", "meeny", "miny", "moe") .filter (x->
Given an IntStream, which method would you use to obtain an equivalent parallel IntStream? A. parallelStream()B. parallels()C. getParallelStream()D. parallel()E. getParallel()F. None of the above.
Which statement is true?A. All lambdas can be converted to method references, and vice versa.B. All lambdas can be converted to method references, but not vice versa.C. All method references can be converted to lambdas, but not vice versa.D. None of the above.
The following diagram shows input arguments being used in three functional interface methods of unknown type. Which three functional interfaces, inserted in order from left to right, could be used to complete the diagram? int ? ? ? int Double int
Which of the following is not a functional interface in the java.util.function package? (Choose two.)A. DoublePredicateB. LongUnaryOperatorC. ShortSupplierD. ToIntBiFunctionE. ToStringOperator.
What is the output of the following application? A. [JENNY, GRACE]B. [ted]C. [tps.Boss@4218224c, tps.Boss@815f19a]D. The code does not compile because of the lambda expression.E. The code does not compile for a different reason. package tps; import java.util.*; class Boss { private String
Which lambda can implement this functional interface? A. () -> System.out.println()B. n -> System.out.println(n)C. () -> trueD. n -> trueE. None of the above. public interface Serval { static void printName (String name) {} boolean cat (String name) { return true; } }
How many of these lines compile? A. OneB. TwoC. ThreeD. FourE. FiveF. Six. 17: Comparator 18: Comparator false; String> c2 (s1, s2) > false; pl String s> false; p2 = (String s) -> false; s1= Strings -> false; s2 = (String s) > false; = =
Which method is not available on the IntSummaryStatistics class?A. getCountAs Long ()B. getMax ()C. toString()D. None of these methods is available.E. All of these methods are available.
Which functional interface, when filled into the blank, allows the class to compile? A. ConsumerB. FunctionC. SupplierD. UnaryOperatorE. None of the above. package sleep; import java.util. function. *; class Sheep {} public class Dream { } int MAX SHEEP = 10; int sheepCount; public void count
Given an instance of Stream s and Collection c, which of the following are valid ways of creating a parallel stream? (Choose three.) A. c.parallel()B. c.parallel().parallelStream()C. c.parallelStream()D. s.parallelStream()E. c.parallelStream().parallel()F. s.parallel()
What is true of the following code? (Choose two.) A. As written, the code prints one line.B. As written, the code prints two lines.C. As written the code does not compile.D. If line 7 is uncommented, the code prints one line.E. If line 7 is uncommented, the code prints two lines.F. If line 7
What is the minimum number of intermediate operations that can fill in each box [M, N, O, P] to have the pipeline complete given any intermediate operation? A. [0, 0, 0, 1]B. [0, 0, 1, 0]C. [0, 0, 1, 1]D. [1, 1, 0, 1]E. [1, 1 ,1, 0]F. [1, 1, 1, 1] Source Finite Stream Source Finite Stream
Given the table in the previous question, how many of the boxes in the Intermediate Operation column will have the pipeline complete regardless of which intermediate operation is placed in the box? A. ZeroB. OneC. TwoD. ThreeE. Four. Source Finite Stream Source Finite Stream Source Infinite
Which of the following declares a Comparator where all objects are treated as equal?A. Comparator comp = (c1) -> 0;B. Comparator comp = (c1) -> {0};C. Comparator comp = (c1, c2) -> 0;D. Comparator comp = (c1, c2) -> {0};E. None of the above.
Which can fill in the blank so this code outputs true? A. Only anyMatchB. Only allMatchC. Both anyMatch and allMatchD. Only noneMatchE. The code does not compile with any of these options. import java.util. function. *; import java.util.stream.*; public class Hide And Seek { public static
Which method reference can replace the lambda on the second line so the output is the same? A. s::contains(a)B. s::containsC. String::contains(a)D. String::containsE. The supplied code does not compile.F. None of the above. var s = "fish"; Predicate pred System.out.println(pred.test("is"));
How many of these lines compile? A. 0B. 1C. 2D. 3E. 4F. 5 Predicate Predicate Predicate Predicate Predicate pred1 = (final String s) ->s.isEmpty(); pred2 = (final s) ->s.isEmpty(); pred3 = (final var s) -> s.isEmpty(); pred4 = (String s) -> s.isEmpty(); pred5 = (var s) ->s.isEmpty();
What is the output of the following application? A. 0B. 2C. 3D. The code does not compile because of the lambda expression.E. The code does not compile for a different reason. package pet; import java.util.*; import java.util. function. *; public class DogSearch { void reduceList (List names,
What does the following output? A. [tire-][wheel-]B. tire-wheelC. None of the above.D. The code does not compile. Set set = new HashSet (); set.add("tire-"); List list = new LinkedList (); Deque queue = new ArrayDeque (); queue.push("wheel-"); Stream.of (set, list, queue) .flatMap(x->
How many lines does this code output? A. One.B. Two.C. Three.D. None. The code does not compile.E. None. The code throws an exception at runtime. 1: import java.util.*; 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:} public class PrintNegative { public static void main(String [] args) { List list = new
How many of the following lines compile? A. NoneB. OneC. TwoD. ThreeE. FourF. Five. 8: IntFunction 9: IntFunction 10: IntFunction IntFunction 11: 12: IntFunction f1 = (Integer f) -> f; (v) -> null; f2 = f3 = S -> s; f4 = () -> 5; f5 = () > Integer.value0f (9) ;
Which statements about using a parallel stream instead of a serial stream are correct? (Choose three.) A. The number of threads used is guaranteed to be higher.B. It requires a stateful lambda expression.C. The stream operation may execute faster.D. The stream operation may execute
Which is a possible output of the following code snippet? A. {false=[Stonehenge, Statue of Liberty], true=[Eiffel Tower, Mount Fuji]}B. {false=[Stonehenge], true=[Mount Fuji, Eiffel Tower, Statue of Liberty]}C. {false=[Mount Fuji, Stonehenge], true=[Eiffel Tower, Statue of Liberty]}D. Exactly
Which can independently fill in the blank to output No dessert today? A. get("No dessert today")B. orElse("No dessert today")C. orElseGet(() -> "No dessert today")D. orElseThrow()E. None of the above. import java.util.*; public class Dessert { } public static void main(String[] yum) {
What is the output of this code? A. bloatB. BLOATC. oneD. ONEE. The code does not compile due to line x.F. None of the above. List.of("one", "two", "bloat") .limit (1) .map (String: : toUpperCase) .sorted () .forEach (System.out::println); // line x
Which is one of the lines output by this code?A. []B. [8]C. [9]D. [10]E. The code does not compile. 10: var list = new ArrayList (); 11: list.add (10); 12: List.add(9); 13: list.add(8); 14: 15 var num = 9; 16: list.removeIf (x -> {int keep = num; return x == keep; }); 17:
What is the output of the following? A. 689B. 986C. The code does not compile.D. The code compiles but throws an exception at runtime. import java.util.Comparator; import java.util.stream.Stream; public class Compete { public static void main(String[] args) { Stream Integer> is = Stream. of
What can a lambda implement?A. All functional interfacesB. Any interfaceC. Only functional interfaces in the JDKD. None of the above.
What is the output of the following application? A. Plenty!B. On Backorder!C. The code does not compile because of the checkInventory() method.D. The code does not compile for a different reason. package lot; import java.util.function. *; public class Warehouse { private int quantity = 40;
What is a possible output of the following application? A. {0.0=[Cold!], 72.0=[HOT!, Just right!]}B. {0.0=[Cold!], 72.0=[Just right!] , 72.0=[HOT!]}C. The code does not compile because of line k1.D. The code does not compile because of line k2.E. The code does not compile because of line
What is the name of a file that declares a module?A. mod.javaB. mod-data.javaC. mod-info.javaD. module.javaE. module-data.javaF. module-info.java
Suppose you have a module that contains a class with a call to exports(ChocolateLab.class). Which part of the module service contains this class?A. ConsumerB. Service locatorC. Service providerD. Service provider interfaceE. None of the above.
Which are considered part of a service? (Choose two.)A. ConsumerB. Service locatorC. Service providerD. Service provider interface
Given the following diagram, how many of the following are named modules? A. 0B. 1C. 2D. 3E. 4 classpath dog.fluffy.jar dog.fluffy dog.husky.jar dog.husky module-info module path dog.hair.jar dog.hair dog.bark.jar dog.bark module-info
Which of the following statements are true? (Choose two.)A. It is a good practice to add the --add-exports option to your java command.B. It is permitted, but not recommended, to add the --add-exports option to your java command.C. There is no --add-exports option on the java command.D. It is a
How many of the following are legal module-info.java files? A. NoneB. OneC. TwoD. ThreeE. Four. module com.koala { exports cute; } module com-koala { exports cute; } public module com.koala { exports cute; } public module com-koala { exports cute; }
Which two would be best to combine into a single module?A. Consumer and service locator.B. Consumer and service providerC. Consumer and service provider interfaceD. Service locator and service provider interfaceE. Service locator and service providerF. Service provider and service provider
What command could you run to print output like the following? A. java --all-modulesB. java --describe-modulesC. java --list-modulesD. java --output-modulesE. java --show-modulesF. None of the above. java.base@11.0.2 java.compiler@11.0.2 java.datatransfer@11.0.2 java.desktop@11.0.2 .
Suppose we have an automatic module on the module path named dog-arthur2.jar and no Automatic-Module-Name specified? What module name should named modules use to reference it? A. dog-arthurB. dog-arthur2C. dog.arthurD. dog.arthur2E. None of the above
Given the dependencies in the diagram, which boxes represent the service provider interface and service provider, respectively? A. W and XB. W and ZC. X and YD. X and ZE. Y and ZF. None of the above. W Y X Z
Using the diagram in the previous question, which boxes represent the consumer and service locator, respectively? A. W and XB. W and ZC. X and YD. X and ZE. Y and ZF. None of the above. W Y X Z
What is the minimum number of JAR files you need for a cyclic dependency? A. 0B. 1C. 2D. 3E. 4
Fill in the blank with code to look up and call a service. A. Mouse.get()B. Mouse::getC. Provider.get()D. Provider::getE. None of the above. String cheese .map(_ .map (Mouse: : favorite Food) .findFirst() .orElse (""); = ServiceLoader.load (Mouse.class)
Suppose we want to have two modules: com.ny and com.sf. Which is true about the placement of the module-info.java file(s)? A. One module-info.java file is required in position Z.B. Two module-info.java files are required, in positions V and X.C. Two module-info.java files are required, in
Consider the modules in the previous diagram. Suppose we want the code in module com.sf to depend on code in module com.ny. Which of the following directives goes into module com.sf’s module-info file to configure that behavior? A. export com.ny;B. exports com.ny;C. require com.ny;D. require
Which options are commonly used when compiling a module? A. -d and -mB. -d and -pC. -m and -pD. -d, -m, and -pE. None of the above.
Which of the following are modules supplied by the JDK? (Choose three.) A. java.baseB. java.basicC. java.desktopD. java.sdkE. java.sqlF. java.swing
Which best describes a top-down migration? (Choose two.)A. The first step is to move all the modules to the module path.B. The first step is to move a single module to the module path.C. Most steps consist of changing an automatic module to a named module.D. Most steps consist of changing an
Suppose the consumer, service locator, service provider, and service provider interface are each in separate modules. Which of the following best describes the following module-info file? A. ConsumerB. Service locatorC. Service providerD. Service provider interfaceE. None of the above. module
Suppose you have these two JARs from Java 8. Which steps, when taken together, would be the best way to make them modules? (Choose two.) A. Add a module-info.java to each.B. Add them to the classpath.C. Create a third module to contain the common code.D. Merge them into one module to break
Which command produces output such as the following?animal.puppy -> animal.dog.A. jdeps –d zoo.animal.puppy.jarB. jdeps –s zoo.animal.puppy.jarC. jmod –d zoo.animal.puppy.jarD. jmod –s zoo.animal.puppy.jarE. None of the above.
Suppose the consumer, service locator, service provider, and service provider interface are each in separate modules. Which of the following best describes the following moduleinfo file? A. ConsumerB. Service locatorC. Service providerD. Service provider interfaceE. None of the above module
Suppose the consumer, service locator, service provider, and service provider interface are each in separate modules. Which of the following best describes the following module-info file? A. ConsumerB. Service locatorC. Service providerD. Service provider interfaceE. None of the above module
What is a benefit of using modules? (Choose two.)A. Better access controlB. Custom Java buildsC. Elimination of JAR filesD. Fewer .java files needed in your applicationE. Not necessary to specify types of local variablesF. Write once, run anywhere.
Suppose the consumer, service locator, service provider, and service provider interface are each in separate modules. Which of the following best describes the following module-info file? A. ConsumerB. Service locatorC. Service providerD. Service provider interfaceE. None of the above module
Which types of modules are allowed to contain a module-info file?A. Automatic onlyB. Named onlyC. Unnamed only.D. Automatic and namedE. Automatic and unnamedF. Named and unnamed.
Which of the following is true of the following module declaration? A. The first line that fails to compile is line 1.B. The first line that fails to compile is line 2.C. The first line that fails to compile is line 3.D. The first line that fails to compile is line 4.E. The code compiles. 1:
How many of these keywords can be used in a module-info.java file: closes, export, import, require, and uses? A. NoneB. OneC. TwoD. ThreeE. FourF. Five.
Suppose the consumer, service locator, service provider, and service provider interface are each in separate modules. Which of the following best describes the following module-info file? A. ConsumerB. Service locatorC. Service providerD. Service provider interfaceE. None of the above. module
Which of the following are modules supplied by the JDK? (Choose three.)A. jdk.baseB. jdk.basicC. jdk.desktopD. jdk.javadocE. jdk.jdepsF. jdk.net
Which are true statements about types of migration? (Choose three.)A. All modules are immediately moved to the module path in a bottom-up migration.B. All modules are immediately moved to the module path in a top-down migration.C. Modules migrate before the modules that depend on them in a
A class in which of the following parts of a module service should include a method call to load(ChocolateLab.class) that would allow callers to use it? A. ConsumerB. Service locatorC. Service providerD. Service provider interfaceE. None of the above.
How many of these module declarations are valid? A. ZeroB. OneC. TwoD. ThreeE. FourF. Five. module com. leaf {} module com.leaf2 {} module com-leaf { } module LEAF {} module leaf2 {}
Which is a benefit of ServiceLoader?A. It allows you to add functionality without recompiling the application.B. It allows you to load a service written in C++.C. It is an interface.D. When implementing a service, it references the ServiceLoader.
Which are true statements? (Choose two.)A. Code on the classpath can reference code in automatic, named, and unnamed modules.B. Code on the classpath can reference code in named modules, but not automatic and unnamed modules.C. Code on the classpath can reference code in automatic and named
Suppose we have the packages in the diagram. What could we add to the module-info.java in com.duck to allow the com.park module to reference the Duckling class but not allow the com.bread module to do the same? A. exports com.duckling;B. exports com.duckling from com.park;C. exports
Given the diagram in the previous question, what could we add to module-info.java in com.duck to allow the com.park package to reference the Duckling class, but not allow the Egg class to reference the Duckling class?A. exports com.duckling;B. exports com.duckling from com.park;C. exports
Given the diagram in question 43 and the correct export statement to share only com. duckling, which of the following should be included in the module-info.java file of com.park to specify that com.park should have access to the com.duckling and com. bread packages, but not the com.egg
Which is both part of the service and has a provides directive?A. ConsumerB. Service locatorC. Service providerD. Service provider interfaceE. None of the above.
What command is the simplest way to list suggestions for classes in jdk.unsupported?A. jdeps cookie.jarB. jdeps –s cookie.jarC. jdeps –jdkinternals cookie.jarD. jdeps --jdkinternals cookie.jarE. jdeps -jdkunsupported cookie.jarF. jdeps --jdkunsupported cookie.jar.
Which modules are on the classpath?A. Automatic onlyB. Named onlyC. Unnamed onlyD. Automatic and namedE. Automatic and unnamedF. Named and unnamed.
Which line of code belongs in a service locator?A. ServiceLoader loader = ServiceLoader.load();B. ServiceLoader loader = ServiceLoader.load(Mouse.class);C. ServiceLoader loader = ServiceLoader.load();D. ServiceLoader loader = ServiceLoader.load(Mouse.class);E. Mouse loader =
Which is true about a service? (Choose two.)A. Changing the service provider interface always requires recompiling the service provider.B. Changing the service provider interface sometimes requires recompiling the service provider.C. Changing the service provider interface never requires
Which modules are on the module path?A. Automatic onlyB. Named onlyC. Unnamed onlyD. Automatic and namedE. Automatic and unnamedF. Named and unnamed.
The service locator and service provider interface share a module. Which boxes represent the consumer and service provider, respectively? A. X and YB. X and ZC. Y and ZD. Z and ZE. Z and YF. None of the above. X Y Z
What command is the simplest way to list what modules a JAR depends on without listing package names? A. jdeps cookie.jarB. jdeps –s cookie.jarC. jdeps –jdkinternals cookie.jarD. jdeps --jdkinternals cookie.jarE. jdeps -jdk-unsupported cookie.jarF. jdeps --jdk-unsupported cookie.jar.
What is a benefit of using modules? (Choose three.)A. Ability to reuse codeB. Clearer dependency managementC. Improved performanceD. Multithreading supportE. Platform independenceF. Unique package enforcement.
Fill in the blanks to list a way of getting a lot of information useful in debugging modules: _______ -m x –p y --______________.A. jar and –show-modulesB. jar and –show-module-detailC. jar and –show-module-resolutionD. java and –show-modulesE. java and –show-module-detailF. java
Showing 300 - 400
of 1045
1
2
3
4
5
6
7
8
9
10
11
Step by Step Answers