Each section below contains either a multiple choice question or a problem to solve. Please select the correct answer or provide the solution to each problem.

Customer
id name street city state
1 Martin Bros 406 Viking Rd Cedar Falls IO
2 Martins Mart 408 Viking Rd Cedar Falls IO
...
Sales_Order
id customer_id item_id order_number quantity amount
1 1 1 B201901011135101231 1 20.00
2 1 2 M201901021137103231 1 15.00
...

The tables above could have hundreds of thousands of rows. You have been tasked with retrieving some key data from these tables.

  1. Find all Customers who do not have any Sales Orders
    1. Create a query using a LEFT JOIN in the query
    2. Create a query using a Subquery
  2. Create a query to find the average price each Customer pays for each Item ordered
  3. Create a query to add a new Sales Order with the following data
    • Amount : 50
    • Customer : 1
    • Quantity : 3
    • Sales Order : B201911210924551000
    • Item : 23
  4. An error occured mistakenly adding the item with id 2 to Sales Orders for the Martin Bros customer account. The mistake only occured on Sales Orders with a prefix of 'M'. Create a query to delete instances of this item from Sales_Orders for the Martin Bros customer account.

Reflecting on the previous question, the Sales_Order table had a field order_number. As an alpha-numeric field, we are unable to leverage sequencing within the database. This sales order number must be a unique value. As such a race condition is possible when users submit an order at the same time. Please answer the following questions pertaining to how Race Conditions can be managed so Dead Lock does not occur.

  1. What Java keyword can be used to ensure only one thread can execute a block of code at a time?
  2. What Java modifier can be used to ensure reading a variable's value is always the latest value?
  3. What Java package can be leveraged for ensuring thread safety for objects and variables?

How could the following API endpoint be improved?

						
@GET
@Path("report")
public Response searchItems(@QueryParam("search") String search,
		@QueryParam("customerId") Integer customerId,
		@QueryParam("brandFilters") String brandFilters,
		@QueryParam("categoryFilters") String categoryFilters,
		@QueryParam("orderGuide") Integer orderGuideId,
		@QueryParam("orderGuideOnly") String orderGuideOnly,
		@QueryParam("page") Integer page,
		@QueryParam("rows") Integer pageSize,
		@QueryParam("sort") String sortValue) {
		
	List selectedBrands = Arrays.asList(brandFilters.split(","));
	List selectedCategories = Arrays.asList(categoryFilters.split(","));
	boolean isOrderGuideItemsOnly = Boolean.parse(orderGuideOnly);
	
	Customer customer = customerDao.findById(customerId);
	List itemList = itemDao.searchItems(search, customerId, isOrderGuideItemsOnly, orderGuideId, page, pageSize, selectedBrands, selectedCategories);
	
	JsonArrayBuilder builder = Json.createArrayBuilder();
	
	for (Item item : itemList) {
	
		if (customer.canViewInactiveItems() || item.isActive()) {
			builder.add(Json.createObjectBuilder()
				.add("id", item.getId())
				.add("name", item.getName())
				.add("stockQty", item.getStockQuantity())
				.add("price", item.getPrice()));
		}		
	}
	
	return Response.ok(builder.build()).build();
}						
						
					

Assuming the body tag of the webpage contains the attribute onload="onLoad()", what error will occur when the text input with id 'input' is changed?

						
var view = {
	name : null,
	
	handleNameChangedEvent : function (event) {
		this.setName(event.currentTarget.value);
		console.log(this.name);
	},
	
	setName : function (nameString) {
		this.name = nameString;
	}
};

function onLoad() {
	document.getElementById('input').addEventListener('change', view.handleNameChangedEvent);
}
						
					

Create a function that will print the numbers from 1 to 100. If the number is a multiple of 3 print FIZZ in place of the number. If the number is a multiple of 5 print BUZZ in place of the number. If the number is a multiple of 3 and 5 print FIZZBUZZ in place of the number.

Conditional Formatting Output

Create an array of Person objects, and function(s) necessary to print a hierarchy of the Person objects. Each Person object should only have two attributes 'name' (String) and 'children' (Array). When printing a Person, the name should be printed after a dash. Each child of a Person should be indented by a single dash.

Expected Output:
-Jane
-Jack
--Kate
---Sayid
---Sun
--Aaron
---Hugo
--Sawyer

Printing Objects Output

The Rules

  • A game consists of 10 frames.
  • A frame consists of one or two throws.
  • At the beginning of a frame there are ten pins standing up.
  • For each frame you score points equal to the number of pins you knock down.
  • If you knock down all of the pins on your first ball that frame ends and you include in the score for that frame the next two balls.
  • If you knock down all of the pins on your second ball you include in the score for that frame the next ball.
  • If you knock down all the pins in the first ball of the last frame you get two extra throws.
  • If you knock down all the pins with the second ball of the last frame you get one extra throw.
Game 1 - Total: 82
1 2 3 4 5 6 7 8 9 10
9 - 0 3 - 5 6 - 1 3 - 6 8 - 1 5 - 3 2 - 5 8 - 0 7 - 1 8 - 1
Game 2 - Total: 131
1 2 3 4 5 6 7 8 9 10
9 - 0 3 - / 6 - 1 3 - / 8 - 1 5 - / 0 - / 8 - 0 7 - / 8 - / - 8
Game 3 - Total: 193
1 2 3 4 5 6 7 8 9 10
X 3 - / 6 - 1 X X X 2 - / 9 - 0 7 - / X - X - X

Below is a function that calculates the final score for a game of bowling. The first game is being used as a test case but is returning the wrong total.

  • Fix the function to return the correct total value.
  • Refactor the function to handle special conditions and properly score game 2 above
  • Complete the problem by properly scoring game 3
Bowling Output

Your submission has been accepted.Thank you!

An unexpected error occured. Please try again, or contact Support