0% found this document useful (0 votes)
16 views4 pages

Coding Practice Exercises Overview

The document provides coding practice exercises and questions for an interview candidate to answer. It includes: 1) An exercise to count the number of occurrences of each day of the week in a month. 2) An explanation of why an AVG function cannot be used in a WHERE clause and how to fix the SQL query. 3) Ways to identify a user connecting to a web service, such as HTTP authentication or digital signatures. 4) An explanation of what HTTP status code 409 means with an example of trying to post a duplicate record. 5) Using vowel counts in words to determine the price of an unknown item. 6) Reasons manhole covers are round rather

Uploaded by

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

Coding Practice Exercises Overview

The document provides coding practice exercises and questions for an interview candidate to answer. It includes: 1) An exercise to count the number of occurrences of each day of the week in a month. 2) An explanation of why an AVG function cannot be used in a WHERE clause and how to fix the SQL query. 3) Ways to identify a user connecting to a web service, such as HTTP authentication or digital signatures. 4) An explanation of what HTTP status code 409 means with an example of trying to post a duplicate record. 5) Using vowel counts in words to determine the price of an unknown item. 6) Reasons manhole covers are round rather

Uploaded by

Priyanka mestry
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Coding Practice Exercise - 01

(Use Any programming Language which you comfortable, Post your answer to me separately)

1: Print HELLO for the given string "AHCECLWLXO"

2: Print HELLO in CAPITAL letters for the given string "ahceclwlxo"

Raj:

Coding Practice Exercise - 07

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

1: Ask user to input starting day and the number of days in a month. Find the number of times every
day occurs in that month. Ex: Input : Number of days in month = 30 , First day = Tuesday

Output : Monday=4, Tuesday=5, Wednesday=5, Thursday=4, Friday=4, Saturday=4, Sunday=4;

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

import [Link].*;

import [Link].*;

public class GfG{

// function to find occurrences

public static void occurrenceDays(int n, String firstday)

// stores days in a week

String[] days = new String[]{ "Monday",

"Tuesday", "Wednesday",

"Thursday", "Friday",

"Saturday", "Sunday" };

// Initialize all counts as 4.

int[] count = new int[7];


for (int i = 0; i < 7; i++)

count[i] = 4;

// find index of the first day

int pos = 0;

for (int i = 0; i < 7; i++)

if (firstday == days[i])

pos = i;

break;

// number of days whose occurrence

// will be 5

int inc = n - 28;

// mark the occurrence to be 5 of n-28 days

for (int i = pos; i < pos + inc; i++)

if (i > 6)

count[i % 7] = 5;

else

count[i] = 5;

// print the days

for (int i = 0; i < 7; i++)


{

[Link](days[i] + " " + count[i]);

// Driver function

public static void main(String argc[]){

int n = 31;

String firstday = "Tuesday";

occurrenceDays(n, firstday);

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

2: What’s wrong in the following query?

SELECT subject_code, AVG (marks)

FROM students

WHERE AVG(marks) > 75

GROUP BY subject_code;

"AVG" is a type of "Multirows function (MRF)" and we cannot write MRF's in WHERE clause because
MRF's executes group-by-group and WHERE clause executes row-by-row. But we can write MRF's in
having clause. So the correct query would be

SELECT subject_code,AVG(marks)

FROM students

GROUP BY subject_code

HAVING AVG(marks)>75

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

3: If a client connects to a web service, how do we identify the user?


HTTP includes built-in support for Basic and Digest [Link] Digital Signature (SOAP-DSIG)
leverages public key cryptography to digitally sign SOAP messages. It enables the client or server to
validate the identity of the other party.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

4: What HTTP Status Code 409 states in web-service, explain with example.

If there is a record exist in DB and we do post for that same record in that case server will return 409
error code

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

5: An apple costs 40 cents, a banana costs 60 cents, and a grapefruit costs 80 cents. How much does a
pear cost?

Apple-> 2 vowels -->40cents : Banana-->3 vowels-->60cents : Grapefruit-->4 vowels -->80cents :

So from above examples we can say that each vowel is equals to 20cents. So Pear --> 2 vowels-->
40cents. So answer is Pear costs 40cents.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

6: Why are manhole covers round and not square?

A: A manhole round can be rotate in any ways and it will not fall into it. So it is safer to use round than
square. Square will fall in to it

B: Manhole cover is round because we can transfer that cover from one place to another by simply
rotating the cover , so it more easier than any other shapes

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

7: Is it better to be perfect and late, or good and on time?

As a general rule, managers prefer “good and on time”, as they don’t appreciate work to stay pending
because of the employees’ need for perfection.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

8: Describe a bad experience you had working with your ex-employer

Never bad-mouth previous colleagues and ex-employees. Instead of focusing on the details of the
incident, put more emphasis on the part where you managed to make him see your point-of-view.

For example − “They were thinking from a different point of view, but in the end, they managed to
understand my concerns as well.”

Common questions

Powered by AI

The cost of fruits is attributed to the number of vowels in their names, with each vowel valued at 20 cents. For instance, an apple with 2 vowels costs 40 cents, a banana with 3 vowels costs 60 cents, and a grapefruit with 4 vowels costs 80 cents. Therefore, a pear with 2 vowels also costs 40 cents .

Multirow functions (MRF) like AVG cannot be used in the WHERE clause because they execute group-by-group, while the WHERE clause executes row-by-row. Instead, MRFs should be used in the HAVING clause after grouping .

When describing a negative experience with a previous employer, focus on understanding rather than criticism. Emphasize how differences in viewpoint were resolved and avoid bad-mouthing previous colleagues or ex-employees, focusing instead on mutual understanding and resolution .

To determine the number of occurrences of each weekday in a month, you first set all weekdays to have a baseline occurrence of four. Then, compute the extra days beyond 28 to distribute across the weekdays starting from the given starting day. For example, if the month has 31 days starting on a Tuesday, there are 3 extra days. Tuesday, Wednesday, and Thursday will therefore occur 5 times, while the rest will occur 4 times .

Managers generally prefer "good and on time" rather than "perfect and late" because they value the completion of work without delays and are averse to pending work due to an employee's pursuit of perfection .

Web services authenticate clients by using Basic and Digest authentication supported by HTTP. Furthermore, SOAP Digital Signatures (SOAP-DSIG) leverage public key cryptography to digitally sign SOAP messages, allowing validation of the identities between the client and server .

A server would return an HTTP Status Code 409 when a request conflicts with the current state of the server, such as attempting to create a resource that already exists. For instance, reposting a record that already exists in the database could trigger this error .

Round manhole covers are preferred because they cannot fall through the circular opening, unlike square covers, enhancing safety. Additionally, round covers can be easily rolled to be moved, making transportation simpler compared to other shapes .

You might also like