QuestionQ41

Java Platform Module System

Given:

Question Image

and

Question Image

Which two entries should the module-info file contain to represent the service provider interface?

  • A exports com.transport.vehicle.cars;
  • B provides com.transport.vehicle.cars.impl.CarImpl to com.transport.vehicle.cars.Car;
  • C requires com.transport.vehicle.cars.Car;
  • D exports com.transport.vehicle.cars.Car;
  • E requires com.transport.vehicle.cars;
  • F exports com.transport.vehicle;
Explanation

A module exports the package com.transport.vehicle.cars to make the public Car service type accessible. The provider registration must be written as provides com.transport.vehicle.cars.Car with com.transport.vehicle.cars.impl.CarImpl;. A requires directive refers to a module name, not a Java package or class. Therefore, among the supplied choices, only A is correct; the requested second directive is absent or misstated. Oracle documents the required provides <service> with <implementation> form.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!