IS5103 Lesson-12

1.Which of the following statements are true about a module containing a
file named module-info.java? The content of the file is:
module com.food.supplier {}
Each correct answer represents a complete solution. Choose all that apply.
A) No packages inside the module are automatically exported.
A main method inside the module can be run.

2.Which statement is true of the following module?
|—zoo
|– staff
|– Vet.java
A) The directory structure would be a valid module if module-info.java
were added directly underneath zoo.

3.Complete the given code such that the following command, which is
used to run the program, is correct:
java
_ zoo.animal.talks/zoo/animal/talks/Peacocks
_ modules
A) None of these

4.Which of the following are legal commands to run a modular program
where n is the module name and c is the fully qualified class name?
A) java –module-path x-x -m n/c

5.Suppose module puppy depends on module dog and module dog
depends on module animal. Fill in the blank so that code in module dog
can access the animal.behavior package in module animal
module animal {
__ animal.behavior;
}
A) Exports

6.Which of the following statements are true in a module-info.java file?
Each correct answer represents a complete solution. Choose all that apply.
A) The opens directive allows the use of reflection.
The uses directive declares that an API is called.

7.Suppose module puppy depends on module dog and module dog depends
on module animal. Which lines allow module puppy to access the
animal.behavior package in module animal?
module animal {
exports animal.behavior;
}
module dog {
_ animal; // line S
}
module puppy {
_ dog; // line T
}
Each correct answer represents a part of the solution. Choose all that apply.
A) requires on line T
requires transitive on line S
requires transitive on line T

8.Which are true statements about the following module?
class dragon {
exports com.dragon.fire;
exports com.dragon.scales to castle;
}
A) None of these.

9.Which is the first line to contain a compiler error?
module snake {
exports com.snake.tail;
exports com.snake.fangs to bird;
requires skin;
requires transitive skin;
. }
A) Line 5

10.Which of the following pairs make up a service?
A) Service locator and service provider interface

11.. Suppose you are creating a service provider that contains the following
class. Which line of code needs to be in your module-info.java?
package dragon;
import magic.*;
public class Dragon implements Magic {
public String getPower() {
return “breathe fire”;
}
}
A) provides magic.Magic with dragon.Dragon;

12.Which of the following code compiles and is equivalent to this loop?
List all = new ArrayList<>();
for (Unicorn current : ServiceLoader.load(Unicorn.class))
all.add(current);
A) List all = ServiceLoader.load(Unicorn.class).stream().map(Provider
::get).collect(Collectors.toList());

13.Suppose you have separate modules for a service provider interface,
service provider, service locator, and consumer. If you add a second
service provider module, how many of these modules do you need to
recompile?
A) Zero

14.Suppose you have separate modules for a service provider interface,
service provider, service locator, and consumer. Which module(s) need
to specify a requires directive on the service provider?
A) None of these

15.Suppose you have separate modules for a service provider
interface, service provider, service locator, and consumer. Which
statements are true about the directives you need to specify?
Each correct answer represents a complete solution. Choose all that apply.
A) The consumer must use the requires directive.
The service locator must use the requires directive.
The service locator must use the uses directive.

16.Which of the following modules are provided by the JDK?
Each correct answer represents a complete solution. Choose all that apply.
A) java.base
java.desktop
java.logging
jdk.compiler

17.Which commands are used to create a smaller Java image and work
with native code, respectively?
A) jlink and jmod

18.Which would you expect to see when describing any module?
A) requires java.base mandated

19.Which are true statements about a package in a JAR on the classpath
containing a module-info.java file?
A) It is possible to make the package available to all other modules on
the classpath.

20.A(n) ___ module is on the classpath while a(n)
__ module is on the module path.
Each correct answer represents a complete solution. Choose all that apply.
A) unnamed, automatic
unnamed, named

21.An automatic module name is generated if one is not supplied.
Which of the following JAR filenames and generated automatic module
name pairs are correct?
Each correct answer represents a complete solution. Choose all that apply.
A) emily-1.0.0.jar and Emily
emily-1.0.0-SNAPSHOT.jar and Emily
emily.$.jar and Emily

22.For a top-down migration, all modules other than named modules are
_ modules and are on the __.
A) automatic, module path

23.. Suppose we have a JAR file named cat-1.2.3-RC1.jar, and AutomaticModule-Name in the MANIFEST.MF is set to dog. What should an
unnamed module referencing this automatic module include in moduleinfo.java?
A) None of these

24.Which are true statements?
Each correct answer represents a complete solution. Choose all that apply.
A) An automatic module exports all packages to named modules.
An unnamed module exports no packages to named modules.

25.Which of the following statements are true?
Each correct answer represents a complete solution. Choose all that apply.
A) Modules with cyclic dependencies will not compile.
A cyclic dependency always involves at least two requires statements.

Other Links:



Statistics Quiz




Networking Quiz




See other websites for quiz:



Check on QUIZLET




Check on CHEGG

Leave a Reply

Your email address will not be published. Required fields are marked *