Java Interview Preparation
Configuration and Profiles Interview Questions
Externalized configuration, properties, profiles, environment variables, and secrets.
Configuration and Profiles Interview Focus
Externalized configuration, properties, profiles, environment variables, and secrets.
Interview questions
1. What is the difference between application.properties and application.yml? Beginner
Both formats define configuration. Properties uses key-value lines, while YAML represents nested values with indentation. Choose one style consistently and avoid duplicate keys across both files.
2. What is externalized configuration? Beginner
Externalized configuration keeps environment values outside compiled code. Spring Boot combines sources such as command-line arguments, environment variables, profile files, and application files; higher-precedence sources override lower ones.
3. What is the order of property-source precedence? Advanced
Externalized configuration keeps environment values outside compiled code. Spring Boot combines sources such as command-line arguments, environment variables, profile files, and application files; higher-precedence sources override lower ones.
4. How do you define environment-specific configurations? Beginner
Use profile files such as application-dev.yml and application-prod.yml. Activate one with spring.profiles.active, an environment variable, or a command-line option, and keep secrets outside source control.
5. How do Spring profiles work? Beginner
Use profile files such as application-dev.yml and application-prod.yml. Activate one with spring.profiles.active, an environment variable, or a command-line option, and keep secrets outside source control.
6. How do you activate a profile? Beginner
Use profile files such as application-dev.yml and application-prod.yml. Activate one with spring.profiles.active, an environment variable, or a command-line option, and keep secrets outside source control.
7. How do you read environment variables? Beginner
Use placeholders such as ${DATABASE_URL}, @Value, or @ConfigurationProperties. Define a safe default only when it is appropriate and fail fast for required production values.
8. How do you secure passwords and sensitive configuration? Advanced
Do not commit passwords or tokens. Use environment variables, a secret manager, or platform secret storage, restrict access, rotate secrets, and ensure logs never print them.
9. How do you create custom configuration properties? Intermediate
Create a class with @ConfigurationProperties and enable scanning, then add Bean Validation annotations when needed. Validation at startup catches missing or invalid settings before traffic reaches the application.
10. How do you validate configuration properties? Intermediate
Create a class with @ConfigurationProperties and enable scanning, then add Bean Validation annotations when needed. Validation at startup catches missing or invalid settings before traffic reaches the application.
How to Prepare for Java Technical Interviews
Use this Java technical interview question bank to revise core concepts and practise explaining your decisions clearly. The questions cover Java fundamentals, object-oriented programming, collections, exceptions, multithreading, Spring Boot, Hibernate, databases, and other topics used in real software development interviews.
Start with the fundamentals, then move to scenario-based questions and advanced topics. Filter questions by difficulty to build confidence gradually. A strong answer should define the concept, explain why it matters, and include a practical example when appropriate.
Continue your preparation with the Java tutorials, or explore all interview preparation tracks for managerial and company-focused questions.
