KEMBAR78
Cognizant Interview Guide | PDF | Spring Framework | Information Technology Management
0% found this document useful (0 votes)
48 views3 pages

Cognizant Interview Guide

The document is a comprehensive preparation guide for Cognizant interviews, focusing on SQL, Java, and Spring Boot. It details important interview questions and concepts related to Spring Boot, including its features, auto-configuration, RESTful services, and database connectivity. Additionally, it introduces Spring Profiles for environment-specific configurations and offers examples for clarity.

Uploaded by

mohammadrafis576
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views3 pages

Cognizant Interview Guide

The document is a comprehensive preparation guide for Cognizant interviews, focusing on SQL, Java, and Spring Boot. It details important interview questions and concepts related to Spring Boot, including its features, auto-configuration, RESTful services, and database connectivity. Additionally, it introduces Spring Profiles for environment-specific configurations and offers examples for clarity.

Uploaded by

mohammadrafis576
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

COGNIZANT INTERVIEW COMPLETE PREPARATION GUIDE

SECTION 1: SQL DATABASE IMPORTANT QUESTIONS (Elaborated)

[SQL content remains unchanged]

SECTION 2: JAVA IMPORTANT INTERVIEW QUESTIONS (Elaborated)

[Java Questions 1–25 remain unchanged]

SECTION 3: SPRING BOOT INTERVIEW QUESTIONS (Elaborated)

1. What is Spring Boot? Spring Boot is a project built on top of the Spring Framework that makes it
easy to create stand-alone, production-grade Spring-based applications with minimal
configuration.

Key Features:

• Auto-Configuration
• Embedded servers (Tomcat, Jetty)
• Starter dependencies

• Production-ready features (metrics, health checks)

• How does Spring Boot differ from Spring Framework? | Feature | Spring Framework | Spring
Boot | |--------|------------------|--------------| | Setup | Manual XML/Java Config | Auto-configuration |
| Server | Requires external server | Embedded server (Tomcat/Jetty) | | Deployment | WAR |
JAR (self-contained) | | Starter Modules | Not available | Pre-built starter dependencies |

• What are Spring Boot starters? Pre-defined Maven dependencies to simplify project setup. E.g.,
spring-boot-starter-web , spring-boot-starter-data-jpa .

Example:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

1. What is @SpringBootApplication annotation? A convenience annotation that combines:

2. @Configuration : Indicates class contains Spring beans

3. @EnableAutoConfiguration : Enables auto-configuration

4. @ComponentScan : Scans packages for Spring components

1
5. How does Spring Boot auto-configuration work? It uses @EnableAutoConfiguration and
classpath scanning to automatically configure beans based on libraries present in the classpath.

6. How to create RESTful web services using Spring Boot?

7. Use @RestController and @RequestMapping annotations

8. Return @ResponseBody directly from methods

Example:

@RestController
@RequestMapping("/api")
public class UserController {
@GetMapping("/users")
public List<User> getAllUsers() {
return userRepository.findAll();
}
}

1. What is application.properties/application.yml in Spring Boot? Configuration files used to


customize the application's behavior.

Examples:

server.port=8081
spring.datasource.url=jdbc:mysql://localhost:3306/db

1. How to connect Spring Boot with a database? Use Spring Data JPA and configure datasource
in application.properties .

Steps:

• Add JPA and DB Driver dependency


• Configure DB URL, username, password

• Use JpaRepository for DAO layer

• What is Spring Data JPA? A part of Spring that simplifies data access with automatic
implementation of repositories.

Example:

public interface UserRepository extends JpaRepository<User, Long> {}

1. What are Spring Profiles? Allow you to define multiple configurations for different
environments like dev, test, and prod.

2
Usage:

@Profile("dev")
@Bean
public DataSource devDataSource() { ... }

Would you like more advanced Spring Boot topics like security, testing, or microservices?

You might also like