Hi Friends,
In this post, I'm sharing interview questions asked in Orange Mantra's 2nd round of interview.
You can also read other Interview questions-answers from my other interviews:
Question 1:
Integer i = 127;
Integer j = 127;
Integer ii = 128;
Integer kk = 128;
if( i == j){
System.out.println("true");
}
else{
System.out.println("false");
}
if(ii == kk){
System.put.println("true");
}
else{
System.out.println("false");
}
What will be the output?
Answer:
true
false
Question 2:
What is Serverless architecture?
Answer:
Serverless is a cloud computing execution model where the cloud provider dynamically manages the allocation and provisioning of servers.
A serverless application runs in stateless compute containers that are event-triggered , ephemeral(may last for one invocation) and fully managed by the cloud provider.
Pricing is based on the number of executions rather than pre-purchased compute capacity.
Our applications are installed in terms of cloud functions. There are multiple cloud services that act as Functions as a service [FaaS].
Question 3:
What happens when we call SpringApplication.run() method in main class of SpringBootApplication?
Answer:
Syntax of the class containing main method is:
@SpringBootApplication
public class TestApplication{
public static void main(String[] args){
SpringApplication.run(TestApplication.class); // returns ConfigurableApplicationContext instance
}
}
When we run this class as a java application then our application gets started.
When this method is called, then Spring Container gets started.
Spring container once started is responsible for:
Steps executed under this method:
Question 4:
What are Spring Boot Starter projects. Name some of them?
Answer:
Starters are a set of dependency descriptors that we can include in our application. We get one-stop-shop for all required technologies in our application. without having to hunt through sample code and copy paste loads of dependency descriptors.
e.g.: If we want to get started using Spring and JPA for database access, just include the sprint-boot- starter-data-jpa dependency in the project and we are good to go.
Below is a list of few starter projects provided by Spring Boot:
Question 5:
How does spring enables creating production ready applications in quick time?
Answer:
Spring Boot enables creating production ready applications by providing a few non-functional features out of the box like caching, monitoring, logging and embedded server.
Spring-boot-starter-actuator: For monitoring and tracing of application
Spring-boot-starter-undertow, spring-boot-starter-jetty, spring-boot-starter-tomcat: To pick the choice of Embedded Servlet Container.
Spring-boot-starter-logging: For logging using Logback
Spring-boot-starter-cache: Enabling spring framework's caching support
Question 6:
What is the minimum baseline version for spring boot 1.5 and 2.1.0 versions?
Answer:
Java 8
Question 7:
How many ways are there to create ApplicationContext?
Answer:
If we are using xml configuration using application-context.xml then
ApplicationContext context = new ClassPathXmlApplicationContext("Path to xml file");
If we are using Java configuration, then:
ApplicationContext context = new AnnotationConfigApplicationContext(ConfigClass.class);
That's all for this interview post.
Hope this post helps everybody in their java interviews.
Thanks for reading!!
In this post, I'm sharing interview questions asked in Orange Mantra's 2nd round of interview.
You can also read other Interview questions-answers from my other interviews:
- Java Interview @ Gemini Solutions
- Java Interview @ OLX
- Java Interview @ SAP
- Java Interview @ GalaxE
- Java Interview @ OrangeMantra
- Java Interview @ Concirrus
- Java Interview @ NexGen Solutions
- Java Interview @ Capgemini
- Java Interview @ Dew Solutions
- Java Interview @ Birdeye
- Java Interview @ RBS
- Java Interview @ Virtusa Polaris
- Java Interview @ Rocketalk
- Java Interview @ Aricent
- Java Interview @ WDTS
Question 1:
Integer i = 127;
Integer j = 127;
Integer ii = 128;
Integer kk = 128;
if( i == j){
System.out.println("true");
}
else{
System.out.println("false");
}
if(ii == kk){
System.put.println("true");
}
else{
System.out.println("false");
}
What will be the output?
Answer:
true
false
Question 2:
What is Serverless architecture?
Answer:
Serverless is a cloud computing execution model where the cloud provider dynamically manages the allocation and provisioning of servers.
A serverless application runs in stateless compute containers that are event-triggered , ephemeral(may last for one invocation) and fully managed by the cloud provider.
Pricing is based on the number of executions rather than pre-purchased compute capacity.
Our applications are installed in terms of cloud functions. There are multiple cloud services that act as Functions as a service [FaaS].
- IBM OpenWhisk
- AWS Lambda
- Microsoft Azure Functions
- Google Cloud Functions
- Auth0 Webtask
So, serverless computing [or serverless for short] is an execution model where the cloud provider is responsible for executing a piece of code by dynamically allocating the resources and only charging for the amount of resources used to run the code.
The code typically runs inside stateless containers that can be triggered by a variety of events including Http requests, database events, file uploads, monitoring alerts etc.
Question 3:
What happens when we call SpringApplication.run() method in main class of SpringBootApplication?
Answer:
Syntax of the class containing main method is:
@SpringBootApplication
public class TestApplication{
public static void main(String[] args){
SpringApplication.run(TestApplication.class); // returns ConfigurableApplicationContext instance
}
}
When we run this class as a java application then our application gets started.
When this method is called, then Spring Container gets started.
Spring container once started is responsible for:
- Creating all objects: This is done by component scan. As @SpringBootApplication is a combination of @Configuration , @ComponentScan and @EnableAutoConfiguration.
- Dependency Injection
- Managing the lifecycle of all beans.
Steps executed under this method:
- Application Context is started
- Using application context , auto discovery occurs: @ComponentScan
- All default configurations are setup i.e. based on dependencies mentioned, spring boot automatically sets up defaults.
- An embedded servlet container is started.[No need to setup a separate web server]. Note: Embedded servlet container is launched only if web is mentioned in a dependency.
Question 4:
What are Spring Boot Starter projects. Name some of them?
Answer:
Starters are a set of dependency descriptors that we can include in our application. We get one-stop-shop for all required technologies in our application. without having to hunt through sample code and copy paste loads of dependency descriptors.
e.g.: If we want to get started using Spring and JPA for database access, just include the sprint-boot- starter-data-jpa dependency in the project and we are good to go.
Below is a list of few starter projects provided by Spring Boot:
- sprint-boot-starter-web
- spring-boot-starter-data-jpa
- spring-boot-starter-web-services
- sprint-boot-starter-test
- sprint-boot-starter-data-rest
- spring-boot-starter-jdbc
- spring-boot-starter-security
Question 5:
How does spring enables creating production ready applications in quick time?
Answer:
Spring Boot enables creating production ready applications by providing a few non-functional features out of the box like caching, monitoring, logging and embedded server.
Spring-boot-starter-actuator: For monitoring and tracing of application
Spring-boot-starter-undertow, spring-boot-starter-jetty, spring-boot-starter-tomcat: To pick the choice of Embedded Servlet Container.
Spring-boot-starter-logging: For logging using Logback
Spring-boot-starter-cache: Enabling spring framework's caching support
Question 6:
What is the minimum baseline version for spring boot 1.5 and 2.1.0 versions?
Answer:
Java 8
Question 7:
How many ways are there to create ApplicationContext?
Answer:
If we are using xml configuration using application-context.xml then
ApplicationContext context = new ClassPathXmlApplicationContext("Path to xml file");
If we are using Java configuration, then:
ApplicationContext context = new AnnotationConfigApplicationContext(ConfigClass.class);
That's all for this interview post.
Hope this post helps everybody in their java interviews.
Thanks for reading!!
No comments:
Post a Comment