0% found this document useful (0 votes)
240 views8 pages

Test Report CND0034742 PRF0004839

Uploaded by

Jonathan Franco
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)
240 views8 pages

Test Report CND0034742 PRF0004839

Uploaded by

Jonathan Franco
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/ 8

CND0034742 PRF0004839

Candidate Session Status: completed


E-mail: ID: AJANUS-KHS Created on: 2024-05-25 16:52 UTC
[email protected] Time limit: 60 min. Started on: 2024-05-28 03:17 UTC
Report recipients: Finished on: 2024-05-28 04:17 UTC
[email protected]
[email protected]
Accessed from: 181.199.54.5,
181.199.54.5
Invited by:
[email protected]

 Notes:
N/A

Similarity Check
Status: not found
No similar solutions have been detected.

Test score

52%
Tasks in test Score
1 McqJava1 60%
Submitted in: Multiple-choice questions

2 SpringHealthcheck 44%
Submitted in: Java 8

Canvas Details
The canvas board was not used during that session.

Tasks Details
SOL0005150 PRF0004839 (Desarrollador Backend SpringBoot) – CND0034742 PRF0004839 – task 1 of 2

1. McqJava1 Task Score Correctness Performance


Easy

Multiple-choice task which is testing java


knowledge. 60 Not assessed Not assessed

Task description

Correct answer, candidate's incorrect answer

1.
The following questions concern the Java language.

Assuming that Superclass1 and Superclass2 are valid abstract classes, Interface1 and Interface2 are both valid interfaces, given code:

public class Class extends Superclass1, Superclass2 implements Interface1, Interface2


{
int value;

public Class(int value)


{
this.value = value;
}
}

A) won't compile because it is possible to inherit only from one class.


B) won't compile because it is possible to implement only one interface.
C) won't compile because it is possible to inherit only from one class and implement only one interface.
D) will compile.

2.
Output of given code will be:

public class Main


{
public static void main(String[] args)
{
String a = "string";
String b = new String("string");
String c = a;

System.out.println(a == b);
System.out.println(a == c);
System.out.println(b.equals(c));
}
}

A) False False True


B) True True True
C) False True True
D) True True False

3.
If a local variable of some type is declared without defining its value and we referred to it afterwards, then:

A) it will be equal to some garbage value.


B) code won't compile as you have to define a local variable value before you refer to it.
C) it will be equal to the default value of this variable type.
D) code won't compile as you have to define a local variable value while declaring it.

4.
If a class parameter of some type is declared without defining its value and there is only a default constructor then:

A) it will be equal to some garbage value.


B) code won't compile as you have to define a class parameter value while declaring it.
C) it will be equal to the default value of this variable type.

5.
Given code will print:

public class Main


{
public static void main(String[] args)
{
try
{
new int[]{1, 2, 3};
int sum = 0;

for (int i = 1; i < 4; i++)


{
sum += arr[i];
}
System.out.println("Sum: " + sum);
}
catch (Exception e)
{
System.out.println("Exception was caught!");
}
catch (IndexOutOfBoundsException e)
{
System.out.println("IndexOutOfBoundsException was caught!");
}
}
}

A) nothing, the compilation error will occur


B) Exception was caught!
C) IndexOutOfBoundsException was caught!
D) Exception was caught! IndexOutOfBoundsException was caught!

6.
What is the difference between given class attributes' accessibility:

public class Fizz


{
String buzz;
protected String woof;
}
A) woof will be accessible only within the class Fizz, while buzz will be accessible in any class that inherits from Fizz.
B) buzz will be accessible only within the class Fizz, while woof will be accessible in any class that inherits from Fizz.
buzz will be accessible in any other class that inherits from Fizz and is declared in the same package as Fizz, while woof will be also
C)
accessible in inheriting classes from different packages.
woof will be accessible in any other class that inherits from Fizz and is declared in the same package as Fizz, while buzz will be also
D)
accessible in inheriting classes from different packages.

7.
Which method needs to be implemented in the Rectangle class in order to make the main() function to produce the meaningful output:

public class Rectangle


{
public int height;
public int width;
}

public class Main


{
public void static main(String[] args)
{
Rectangle rectangle = new Rectangle();
System.out.println(rectangle);
}
}

A) Rectangle()
B) toString()
C) toLine()
D) stringFormat()

8.
Which Foo class definition will ensure that it won’t be ever inherited:

A) protected abstract Foo


B) protected Foo
C) static Foo
D) public final Foo

9.
Which interface allows to save an object and reconstruct it at separate JVM:

A) Cloneable
B) Readable
C) Serializable
D) Constructable

10.
To ensure that some function foo() of class Bar, will be implemented separately in every subclass it should be declared as:

A) abstract foo()
B) public synchronized foo()
C) protected abstract foo()
D) protected foo()

Copyright 2009-2024 by Codility Limited. All Rights Reserved. Unauthorized copying, publication or disclosure prohibited.
Solution See Live Version

Programming language used: Multiple-choice questions

Total time used: 60 minutes

Effective time used: 30 minutes

Notes: not defined yet


SOL0005150 PRF0004839 (Desarrollador Backend SpringBoot) – CND0034742 PRF0004839 – task 2 of 2

2. SpringHealthcheck Task Score Correctness Performance


Easy

Implement a simple Spring boot API. 44 44 Not assessed

Task description

You are given a part of Spring MVC application and your task is to build new RESTful web controller.

You should implement two variants of reading the /healthcheck resource using JSON as the response data format:

Method to read simple healthcheck


A request to GET /healthcheck?format=short should return a simple message:

{ "status": "OK" }

Method to read detailed healthcheck


A request to GET /healthcheck?format=full should return the application status and current time (formatted as an ISO 8601 string):

{ "currentTime": "2018-06-06T21:59:36Z", "status": "OK" }

Other requirements and hints


1. Performance is not assessed; focus on correctness and code quality.

2. Your service is expected to handle only GET method. Other methods should return 405 status.

3. If parameters' values do not match the specified possible values or if no parameter is present, you should return HTTP status code 400 ("Bad
Request").

4. Responses should have Content-Type header with appropriate value (application/json).

5. If you need to create multiple classes, you can use nested classes or define multiple classes in one source file.

6. You can use only the following libraries (and their dependencies):

Spring Web MVC (v. 5.0.7.RELEASE)

FasterXML Jackson, Jackson Datatype JSR310 (v. 2.9.6)

Copyright 2009–2024 by Codility Limited. All Rights Reserved. Unauthorized copying, publication or disclosure prohibited.

Solution See Live Version

Programming language used: Java 8

Total time used: 31 minutes

Effective time used: 31 minutes

Notes: not defined yet

Source code

Code: 04:17:09 UTC, java, final, score: 44

1package com.codility.tasks.spring.healthcheck;
2
3import org.springframework.web.bind.annotation.*;
4import org.springframework.web.bind.annotation.RestController;
5import org.springframework.http.MediaType;
6import java.util.HashMap;
7import java.util.Map;
8import java.time.ZonedDateTime;
9import org.springframework.http.HttpStatus;
10import org.springframework.http.ResponseEntity;
11
12@RestController
13class HealthcheckController {
14
15 // Your solution
16
17 @GetMapping(value = "/healthcheck")
18 public ResponseEntity<Map<String,String>> healthcheck(@PathVariable("format") Integer format) {
19 System.out.println("data " + format);
20 Map<String,String> data = new HashMap<>();
21 if(format!= null){
22 data.put("status","OK");
23 if(format.equals("full")){
24 data.put("currentTime","2018-06-06T21:59:36Z");
25
26 }
27 return new ResponseEntity(data, HttpStatus.OK);
28 }else{
29 return new ResponseEntity(HttpStatus.BAD_REQUEST);
30 }
31
32 }
33
34 @PutMapping(value = "/healthcheck")
35 public ResponseEntity<Map<String,String>> healthcheckPut() {
36 return new ResponseEntity(HttpStatus.METHOD_NOT_ALLOWED);
37 }
38
39 @PostMapping(value = "/healthcheck")
40 public ResponseEntity<Map<String,String>> healthcheckPost() {
41 return new ResponseEntity(HttpStatus.METHOD_NOT_ALLOWED);
42 }
43
44
45 @DeleteMapping(value = "/healthcheck")
46 public void healthcheckDelete() {
47 return;
48 }
49
50}

Analysis summary
The following issues have been detected: wrong answers, runtime errors.

Analysis

Correctness tests
com.codility.tasks.spring.healthcheck.SolutionTest - ✔ OK
should_return_405_for_PUT_method
com.codility.tasks.spring.healthcheck.SolutionTest - ✔ OK
should_return_correct_ContentType_header_for_simple_healthcheck
com.codility.tasks.spring.healthcheck.SolutionTest - ✔ OK
should_return_405_for_POST_method
com.codility.tasks.spring.healthcheck.SolutionTest - ✘ WRONG ANSWER
should_return_400_for_invalid_format_query_param_value
com.codility.tasks.spring.healthcheck.SolutionTest - ✘ RUNTIME ERROR
should_return_correct_response_body_for_detailed_healthcheck
com.codility.tasks.spring.healthcheck.SolutionTest - ✘ WRONG ANSWER
should_return_400_for_no_format_query_param_value
com.codility.tasks.spring.healthcheck.SolutionTest - ✘ WRONG ANSWER
should_return_405_for_DELETE_method
com.codility.tasks.spring.healthcheck.SolutionTest - ✘ WRONG ANSWER
should_return_correct_response_body_for_simple_healthcheck
com.codility.tasks.spring.healthcheck.SolutionTest - ✔ OK
should_return_correct_ContentType_header_for_detailed_healthcheck

You might also like