0% found this document useful (0 votes)
177 views23 pages

Hackerrank VERIFIEDD

This document discusses various questions related to Spring, Java, databases and other programming concepts. It covers topics like Spring bean initialization order, Spring AOP pointcuts, Spring Security authentication vs authorization, Spring Boot auto-configuration and annotations, JPA entity conversion, and SQL functions like ROUND.

Uploaded by

Prasad
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)
177 views23 pages

Hackerrank VERIFIEDD

This document discusses various questions related to Spring, Java, databases and other programming concepts. It covers topics like Spring bean initialization order, Spring AOP pointcuts, Spring Security authentication vs authorization, Spring Boot auto-configuration and annotations, JPA entity conversion, and SQL functions like ROUND.

Uploaded by

Prasad
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/ 23

1)How can you define the order of bean initialization when multiple beans depend on each other?

A)Using @Order annotation


B)By specifying depends on attribute
C)Using @Priority annotation
D)Order is always Random

2) public class ArithmeticExample {

public static void main(String[] args) {

double a = 5.5;

double b = 3.0;

double c = Math.pow(a,b);

System.out.println(c);

double d = Math.sqrt(a);

System.out.println(c);

double e = Math.abs(a - b);

System.out.println(e);

double f = Math.max(a, b);

System.out.println(f);

Options

A)166.375

2.345207879911715

5.5
B) 166.375

2.345207879911715

2.5

5.5

C) 166.375

2.345207879911715

3) In HTML5, you are working on Web Forms 20 Which of the following statements about attributes
in the output tag are correct

Statements:

1. The for attribute is used to determine the relationship between the result of the operation and the
elements that is used in the operation

2. The form attribute is used to determine the form to which the output tag is redirected

3. The name attribute is used to determine the name of the output element

A)1 and 2

B)2 and 3

C)1 and 3

D) All of these
4)What is the output of the following code?

class HackerEarth {

int getValue() {

int returnValue = 10;

try {

String[] Languages = {

"Try Block",

"Try block is running"

};

System.out.println(Languages[1]);

} catch (Exception e) {

System.out.println("Catch Block :" + returnValue);

return returnValue;

} finally {

returnValue += 10;

System.out.println("Finally Block :" + returnValue);

return returnValue;

public static void main(String args[]) {

HackerEarth

var = new HackerEarth();

System.out.println("Main Block :" + var.getValue());

}
Options:

1)Try block is running

Finally Block:20

Main Block: 20

2)Catch Block:10

Finally Block :20

Main Block:10

3)Catch Block: 10

Finally Block :20

Main Block: 20

4)Compilation error

5) Choose the correct option

Using the Spring AOP framework, what are the join point methods of the following pointcut
expressions? execution(public**(..))

1) The execution of all public method

2) The execution of all public method returning a value

3) The execution of all public method having at least one parameter

4) The execution of all public method in class belonging to the default java package
6) Which AOP framework does Spring AOP integrate with for advanced AOP features?

1) JAspect

2) AspectC

3) AspectJ

4) WeaveJ

7) Which Spring cloud module is used to externalize the configuration of microservices into a
centralized place?

1) Spring Cloud Netflix

2) Spring Cloud Gateway

3) Spring Cloud OpenFeign

4) Spring Cloud Config

8) In Spring Security, what is the main difference between authentication and authorization?

1) They both refer to the same process

2) Authentication is for verifying identity, while authorization determines what an authenticated


user can access.

3) Authentication grants access, while authorization verifies identity.

4) Both are filters used to block unauthorized requests.

9) John is working on a spring. While working on a application he wants to know the case that
would except the @Transactional annotation applied on an interface to work as excepted. Help him
to find the which of the following can be used in the above-mentioned context

1) The interface is declared as abstract

2) you are using interface-based proxies


A) Only 1

B) Only 2

C) Both 1 and 2

D) None of these

10) Which of the following statements about the default methods in Java are true

Statement

1. It provides a default implementation for a method

2. It is declared by using the keyword default.

3. It can be declared as static or abstract


4. A default method does not have access to the instance of variables of a class that is used to
implement the interface

Options

1)1, 2, and 3

2)1,2 and 4

3)1 and 2

4)2 and 3

11) What is the role of an API gateway in a microservices architecture?

1) To handle authentication and authonzation for services.

2) to provide a single entry point for external clients to access services

3) To route requests to the appropnate service

4) Act as an Service Register


12) Choose the correct Ult format to get a sub-resource by resource id and sub-resource id.

1)(resource)/(resource-id)/(sub-resource)/(sub-resource-id)

2)[resource)(sub-resource)/(sub-resource-id)

3)(sub-resource)/(sub-resource-id)/[resource]/[resource-id)

4)[resource)/(resource-id)/(sub-resource-id)/(sub-resource)

13) How can you define the order of bean initialization when multiple beans depend on each other?

1) Using @Order annotation

2) By specifying depends on attribute

3) Using @Priority annotation

4) Order is always random

14) A bean can have more than or name in spring boot using multiple attributes

1) TRUE

2) FALSE

15) What is the output of the following Java code?

Code:

class Hackjava {

public static void main(String args[]){

int i=1,s=0;

while (i < 6){

s=s+i;

i++;}

System.out.println(s);}}
1)15

2)21

3)1

4) Syntax Error

16) In REST API web services, which of these methods is used to remove configuration on a device

HTTP /devices/(id/configurations/[id]

1) POST

2) DELETE

3) OPTIONS

4) PUT

17) Which of the following REST methods are almost identical to each other?

1)GET and PUT

2) POST and DELETE

3) POST and HEAD

4) GET and HEAD

18)Does Spring Boot require XML Configuration to function?

1) TRUE

2) FALSE
19) What is the default mode of of auto wiring?

1)FALSE

2) byName

3) byType

4) None of the above

20) Which of these method of Thread class is used to Suspend a thread for a period of time?

1)sleep()

2)terminate()

3)suspend()

4)stop()

21) What does Spring Boot do to simplify the configuration of a Spring-based application?

1) Automatically configures necessary beans and dependencies

2) Uses annotations to configure beans and dependencies.

3) Allows for the use of XML configuration files

4) Provides a command line interface for configuring the application

22) Which of the Blowerng statement is correct regarding the difference mce between TRUNCATE,
DELETE and DROP command

1)DELETE operation can be rolled back but TRUNCATE and DROP dperations cannot be leo back

2) TRUNCATE and DROP operations can be rolled back but DELETE operations cannot be ruled

3) DELETE is an example of DML, but TRUNCATE and DROP are examples of DDL

4) All are an example of DDL


Which of the option are correct

Options

A) 2 and 3

B) 1 and 3

C) 2 and 4

D) None of the above

23) You are given to task to develop a spring boot based web application for a client. The
Functionalities and the schema has been specified by the client. How can you achieve annotation-
based auto-wiring in the application?

1) By Providing @Autowired annotation

2) By Providing @selfwired annotation

3) By Providing @Wired-auto annotation

4) By providing @Automaticwired annotation

24) while working on a project using JPA in java Bob made a class. now he wishes to convert a class
into a entity. which among the following options is needed in order to convert it.

Statements

1) Add @Entity annotation

2) Add @Id annotation

3) Add javax.persistence.* package

4) All of the above

Options

1) 1

2) 2

3) 3

4) All of these
25) What is the default logging implementation offered by spring boot?

1) By using Log4j

2) By using Log back

3) By using SLF4J

4) By using JUL(java util Logging)

26) Consider the production table

Table: prostac

Bcode

p_name

Paul

John

Mary

Lisa

Anita

Tara

Price

1015

15.99

15.50

25.25

30.33
15.55

Which of these SQL queries must be used to round off the price to one decimal place in the above
product table?

Statements

1) SELECT p code, price, ROUND (price, 1) FROM product;

2. SELECT p_code, price, TRUNCATE (price, 1) FROM product;

3. SELECT p_code, price, ABS(price, 1) FROM product;

Options

1) 1

2) 2

3) 3

4) all of these

27)Suppose you are on developing spring boot applications. You want to use the spring cloud . But
the application needs to handle heavy traffic. You have to implement load balancing. From the above
info, which method is used to implement it in the spring boot?

1) Cloudload

2) Netflix Ribbon

3) RR balancer

4) Can't implement
28) WebServiceTemplate provides a sendSourceAndReceiveToResult() method that accepts
arguments:- //doubt

a)java.xml.transform.Source

b)java.xml.transform.Result

c)java.xml.transform.Template

d)java.xml.transform.JDBCTemplate

29) Ben wants to use the ApplicationContext IoC container in one of his programs during
development. What classes would can be use for the implementation for the applicationContext?

1) AdvancedApplicationContext, FileApplicationContext

2) FileSystemXmlApplicationContext, ClassPathXmlApplicationContext, WebXmlApplicationContext

3) FileSystemApplicationContext, ClassPathApplicationContext

4) FileSystemApplicationContext, ClassPathApplicationContext,

WebApplicationContext

30) John wants to develop an application in java language. He wants to use the spring boot which is
very flexible and secure. He wants to run his application without relying on an external web server
and reduce the number of executions. Since he used the spring boot framework, it provides the
default project dependencies as well a allows for defaults to be overwritten. Which among the
following features does spring boot annotation include?

1) SpringBootApplication

2) EnableAutoConfiguration

3) ComponentScan

4) All the above


31)John is working on java. While working on an application, he wants to know the difference
between int and double in the data types. Help him to find which of the following is/are statements
are correct about above-mentioned context

Statements

1) int is used for floating-point numbers, while double in used for integers

2) Int is a 64-bit data type, while double is a 32-bit data type

3) int is a signed data type that can hold values from 2,147,483,648 to 2,147,483,647 while double is
a floating-point data type tat can hold very large and very small numberd with the decimal places
4) int is a floating-piont data type that can hold very large and very small numbers with decimal
places, while double is a signed data type that can hold values from -2, 147,483,648 to 2,147,483,647

Options
1)1
2)2
3)3
4)4

32) In CSS, which of these properties helps specify the positioning area of a backend veget

1) background-origin

2) background-origin-area

3) background-position-area

4) None of these
33) Which source code management plugin does Jenkins install by default?

1) None Of The Above

2) GIT

3) SUBVERSION

4) CONCURENT VERSION SYSTEMS

34) John is setting up the credentials in a jenkins system. The credentials are to be added from a
pipeline project. Then what will be choose under this condition

1) System

2) Global

3) Host

4) Server

35) Which of the following rules should be considered while deploying a Microservice-oriented
architecture?

1) Each microservice should be independently deployable.


2) All microservices should be strongly coupled with one another such that changes in ons will not
affect the other

3) Each service unit of the entire application should be the largest and capable of delivering one
specific business goal

4) All of these
36) Which among the following classes is considered as an entry point to an Spring Web MVC
project?

1) DispatcherServlet

2) Dispatch Servlet

3) SpringDispatcherServiet

4) SpringDispatchServlet

37) An organization is required handle 0.96million people every second, in order to control their
heavy traffic, the organization redirects at the all the traffic from one register required to perform the
Y-axis scaling in this scenario to overcome this hindrance then, which of the following action need to
be performed?

1)Run the single server with the same application at a different time.

2) Run the multiple servers with the same application at a different time

3) Run the single server with the same application at the same time.

4) Run the multiple servers with the same application at the same time.

38) In Spring, what are the types of advice?

1) then, after, after-returning, after-throwing and around

2) when, after, after-returning and around

3)where, after, after-returning, after-throwing and around

4) before, after, after-returning, after-throwing and around


39) What is Weaving in Spring AOP?

1) Weaving is the process of linkong an aspect with other application types or objects to create an
advised object

2) It is an expression that is matched with yom points to determine whethes, advice needs to be
executed or not

3) It is the process of creating an object after applying advice to the target object

4) None of these

40) In Spring, which of the following methods is not supported by the Thread class?

1) public void run()

2) public void start()

3) public void exit()

4) public final int getPriority()

41) John is working on java. While working on an application, he wants skip the current iteration of a
loop and move for the next iteration without executes body for the current iteration. Help him to
find which of the following can be used in the above-mentioned context.

1) break

2) exit

3) continue

4)None of the above

42) Ben decided to use the PUT method in his REST API web service. Which of the following is the
reasons to use it in application //doubt

Reasons :

1) It has no side effects on successively calls

2) It is a safe method to use.

3) It either creates or updates the requested resource


Options :

1) 3 only

2) 1 and 3 only

3) 2 and 3 only

4) 1,2 and 3

43) In an application , Ben has designed several endpoints but for just validation purposes, he wants
to know the methods allowed for a particular URL. The endpoint URL is "/store".Which of the
following methods would use to achieve this

1) PATCH

2) GET

3) OPTIONS

4) TRACE

44) Which of the following is a correct interface?

1) interface A { void print()[]}

2) abstract interface A {print():}

3) abstract interface A {abstract void print(): {}}

4) Interface A { void print();}

45) What is the purpose of the Spring Boot Actuator?

1) To provide production-ready features such as monitoring and metrics

2) To provide a way to configure beans using annotations

3) To provide a way to run Spring Boot applications as a service

4) To provide a way to access the underlying database of a Spring Boot application


46) Which of the annotation is not a Spring boot annotation

1)@Controller

2)@RestController

3)@Service

4)@Data

47)Which among the following is not valid Spring Core Framework annotation

1)@PreDestory

2)@PostConstruct

3)@PropertySource

4)@ComponentSource

48) In RESTful web services, you are working on REST based architecture. Which of the following
statements about the HTTP methods that are used in this architecture are correct?

Statements:

1. The GET method is used to provide write-only access to a resource.

2. The POST method is used to create a new resource.

3. The DELETE method is used to remove a resource

4. The PUT method is used to update an existing resource or create a new resource

1)1,2and 3

2) 2,3 and 4

3) 1,2 and 4

4)1, 3 and 4
49) Alice is working on a project on a java J2EE. While writing the code for the required application ,
servlet installation fails. What exception will be thrown for the failure

1) IOException

2) ServletExceotion

3) RemoteException

4) HttpException

50) In REST API. web services, which of these methods is used to remove configuration on a device in
the following

HTTP___/devices/(id)/configurations/(id)

1) POST

2) DELETE

3) OPTIONS

4) PUT

51) What is the name of the thread in output in the following Java program?

class multithreaded_programming

public static void main(String args[])

Theard t = Thread.currentThread();

System.out.println(t.isAlive());

}
Options:

1)0

2)1

3)True

4)False

52) What is the output of the below code

class Hacker{

static int add(int a,int b){

return a*b/a;

static int add(int a,int b,int c){

return a*b/c;

class Hackeroverload{

public static void main(String[] args){

System.out.println(Hacker.add(4,6));

System.out.println(Hacker.add(2,4,6));

Options:

1)6

2)1

3)4

8
4)6

53) What is the output of the following code?

class printhack {

private String name;

public String getName() {

return this.name;

public void setName(String name) {

this.name = name;

class Main {

public static void main(String[] main){

printhack d = new printhack();

d.setName("Hacker");

System.out.println(d.getName());

d.setName("earth");

System.out.println(d.getName());

Statements:

1)Hacker

2)earth

3)Hacker

Earth
4)Error

OPTIONS:

1)1

2)2

3)3

4)Error

You might also like