0 likes | 1 Views
Easily download the EX378 Red Hat Certified Cloud-native Developer Exam Dumps from Passcert to keep your study materials accessible anytime, anywhere. This PDF includes the latest and most accurate exam questions and answers verified by experts to help you prepare confidently and pass your exam on your first try.
E N D
Download Valid EX378 Dumps for Best Preparation Exam : EX378 Title : Red Hat Certified Cloud-native Developer exam https://www.passcert.com/EX378.html 1 / 9
Download Valid EX378 Dumps for Best Preparation 1.Create a configuration property for the application name and inject it into a CDI bean. A. See the Explanation. Answer: A Explanation: 1. Add to application.properties: app.name=CloudNativeApp 2. Create a bean: @ApplicationScoped public class AppNameService { @Inject @ConfigProperty(name = "app.name") String appName; public String getAppName() { return appName; } } 3. Inject AppNameService into a REST endpoint or another bean to use it. 2.Externalize a boolean flag and use it to enable/disable a service method. A. See the Explanation. Answer: A Explanation: 1. In application.properties: feature.enabled=true 2. Inject the flag: @ApplicationScoped public class FeatureService { @Inject @ConfigProperty(name = "feature.enabled") boolean enabled; public String execute() { return enabled ? "Feature is ON" : "Feature is OFF"; } } 3.Use default values when a configuration property is missing. A. See the Explanation. Answer: A Explanation: @ApplicationScoped public class TimeoutService { @Inject @ConfigProperty(name = "request.timeout", defaultValue = "5000") 2 / 9
Download Valid EX378 Dumps for Best Preparation int timeout; public int getTimeout() { return timeout; } } This allows your app to run even if request.timeout is not in the config file. 4.Inject a configuration property into a constructor using MicroProfile Config. A. See the Explanation. Answer: A Explanation: @ApplicationScoped public class DatabaseService { private final String jdbcUrl; @Inject public DatabaseService(@ConfigProperty(name = "db.url") String jdbcUrl) { this.jdbcUrl = jdbcUrl; } public String getJdbcUrl() { return jdbcUrl; } } Ensure db.url is defined in application.properties. 5.Inject a property into a JAX-RS resource class. A. See the Explanation. Answer: A Explanation: @Path("/env") public class EnvResource { @Inject @ConfigProperty(name = "env.type") String envType; @GET public String getEnv() { return "Environment: " + envType; } } Declare env.type=dev in application.properties. 6.Use a configuration property to control bean behavior via conditional logic. A. See the Explanation. Answer: A Explanation: 3 / 9
Download Valid EX378 Dumps for Best Preparation 1. In application.properties: logging.verbose=false 2. In the service: @ApplicationScoped public class LoggerService { @Inject @ConfigProperty(name = "logging.verbose") boolean verbose; public void log(String message) { if (verbose) System.out.println("[VERBOSE] " + message); } } 7.Inject a list of values from a comma-separated property. A. See the Explanation. Answer: A Explanation: supported.locales=en,fr,de @ApplicationScoped public class LocaleService { @Inject @ConfigProperty(name = "supported.locales") List<String> locales; public List<String> getLocales() { return locales; } } MicroProfile config automatically converts the string to List<String>. 8.Inject a map of configuration values using a prefix. A. See the Explanation. Answer: A Explanation: MicroProfile Config does not support direct map injection, but you can use @ConfigProperty with dynamic keys or custom beans. Alternatively, iterate over keys starting with a prefix using ConfigProvider.getConfig(). 9.Inject configuration property into a Quarkus scheduler job. A. See the Explanation. Answer: A Explanation: @ApplicationScoped public class SchedulerBean { 4 / 9
Download Valid EX378 Dumps for Best Preparation @Inject @ConfigProperty(name = "job.message") String message; @Scheduled(every = "10s") void run() { System.out.println("Job says: " + message); } } Define job.message=Hello World. 10.Create a reusable config value class and inject it into multiple beans. A. See the Explanation. Answer: A Explanation: 1. @ApplicationScoped class: @ApplicationScoped public class AppConfig { @Inject @ConfigProperty(name = "app.theme") String theme; public String getTheme() { return theme; } } 2. Inject AppConfig where needed. 11.Inject a property value into a static method using a wrapper class. A. See the Explanation. Answer: A Explanation: 1. Create a bean class with @ApplicationScoped: @ApplicationScoped public class StaticConfigWrapper { @Inject @ConfigProperty(name = "file.path") String filePath; public static String getFilePath(StaticConfigWrapper wrapper) { return wrapper.filePath; } } 2. Pass instance of StaticConfigWrapper to static context. 12.Inject optional configuration property and provide runtime fallback. A. See the Explanation. 5 / 9
Download Valid EX378 Dumps for Best Preparation Answer: A Explanation: @ApplicationScoped public class OptionalService { @Inject @ConfigProperty(name = "optional.message") Optional<String> message; public String fetchMessage() { return message.orElse("Default fallback message"); } } MicroProfile Config allows Optional<T> injection to check if value exists. 13.Create a REST endpoint that exposes configuration values. A. See the Explanation. Answer: A Explanation: @Path("/config") @ApplicationScoped public class ConfigEndpoint { @Inject @ConfigProperty(name = "build.version") String buildVersion; @GET public String getBuildVersion() { return buildVersion; } } Define build.version=1.0.5 in application.properties. 14.Demonstrate programmatic access using ConfigProvider API. A. See the Explanation. Answer: A Explanation: @ApplicationScoped public class DynamicConfigService { public String getConfigValue(String key) { return ConfigProvider.getConfig().getValue(key, String.class); } } This allows access to config keys dynamically without annotations. 15.Validate configuration value range and fail-fast on invalid input. A. See the Explanation. 6 / 9
Download Valid EX378 Dumps for Best Preparation Answer: A Explanation: @ApplicationScoped public class ThresholdService { @Inject @ConfigProperty(name = "threshold.limit") int limit; @PostConstruct public void init() { if (limit < 0 || limit > 100) { throw new IllegalArgumentException("Limit must be between 0 and 100"); } } } Use @PostConstruct to enforce constraints at startup. 16.Log all injected config values from a single source. A. See the Explanation. Answer: A Explanation: @ApplicationScoped public class ConfigLogger { @Inject @ConfigProperty(name = "server.port") int port; @Inject @ConfigProperty(name = "server.host") String host; @PostConstruct public void logConfig() { System.out.println("Server running on " + host + ":" + port); } } Define server.port and server.host in application.properties. 17.Inject a long and a double type config property into a service. A. See the Explanation. Answer: A Explanation: @ApplicationScoped public class PricingService { @Inject @ConfigProperty(name = "item.price") double price; 7 / 9
Download Valid EX378 Dumps for Best Preparation @Inject @ConfigProperty(name = "item.id") long itemId; public String getInfo() { return "Item " + itemId + " costs $" + price; } } Ensure item.price=49.99 and item.id=123456 are defined. 18.Inject enum config property using MicroProfile Config. A. See the Explanation. Answer: A Explanation: 1. Define enum: public enum Mode { DEV, TEST, PROD } 2. Inject into bean: @ApplicationScoped public class ModeService { @Inject @ConfigProperty(name = "app.mode") Mode mode; } 3. Config: app.mode=PROD 19.Use a nested bean to group related configuration properties. A. See the Explanation. Answer: A Explanation: Create a wrapper class and inject individual values into fields: @ApplicationScoped public class EmailConfig { @Inject @ConfigProperty(name = "email.host") String host; @Inject @ConfigProperty(name = "email.port") int port; } Config: email.host=smtp.example.com email.port=587 8 / 9
Download Valid EX378 Dumps for Best Preparation 20.Inject a secret token as a configuration property for authentication. A. See the Explanation. Answer: A Explanation: @ApplicationScoped public class AuthService { @Inject @ConfigProperty(name = "auth.token") String token; public boolean authenticate(String providedToken) { return token.equals(providedToken); } } Store auth.token=supersecrettoken securely via env var or vault in prod. 21.Create a POJO and map multiple configuration properties to it using @ConfigProperties. A. See the Explanation. Answer: A Explanation: 1. Add to application.properties: db.host=localhost db.port=5432 db.user=admin 2. Create a POJO: @ConfigProperties(prefix = "db") @ApplicationScoped public class DBConfig { public String host; public int port; public String user; } 3. Inject DBConfig into another bean. 9 / 9