Java Junior Java Interview Questions -- What to Expect?

  • Thread starter Thread starter Robben
  • Start date Start date
  • Tags Tags
    Interview Java
AI Thread Summary
The discussion centers around preparing for a math-based coding interview for a junior Java internship. The candidate is advised to clarify expectations with the recruiter, which is considered acceptable and beneficial for preparation. The recruiter indicated that the candidate must code a solution to derive a numerical value from a given input, likely in string format. Examples of potential coding tasks include converting a simple string of integers into an integer, extracting numbers from a mixed string, and evaluating mathematical expressions from various formats. Participants emphasize the importance of implementing error handling in the code, suggesting the use of try-catch blocks within loops to manage user input effectively. Overall, the conversation highlights the need for clarity, preparation, and coding proficiency in handling mathematical problems in a programming context.
Robben
Messages
166
Reaction score
2
I am applying for a junior java internship and the recruiter told me there is going to be a math based interview question that I must code. What can I expect from this math based question? Are there general math questions that you can provide me so that I will have a good understanding of what to expect?
 
Technology news on Phys.org
Robben said:
I am applying for a junior java internship and the recruiter told me there is going to be a math based interview question that I must code. What can I expect from this math based question? Are there general math questions that you can provide me so that I will have a good understanding of what to expect?
Have you tried asking the recruiter?
 
Borg said:
Have you tried asking the recruiter?
I thought it would have been bad/taboo to ask the recruiter lol? So it is acceptable to ask the recruiter?
 
Robben said:
I thought it would have been bad/taboo to ask the recruiter lol? So it is acceptable to ask the recruiter?
If I was concerned about my ability to be fully prepared for an interview, I would check with the recruiter to clarify anything that I was unsure about. Maybe that's just me. I did ask for a raise after I got a job once - I got the raise. I think that if you just ask for clarification about the test and present it as wanting to be fully prepared for the interview, you shouldn't break any taboos.

BTW, good luck in the interview.
 
  • Like
Likes Robben
Borg said:
If I was concerned about my ability to be fully prepared for an interview, I would check with the recruiter to clarify anything that I was unsure about. Maybe that's just me. I did ask for a raise after I got a job once - I got the raise. I think that if you just ask for clarification about the test and present it as wanting to be fully prepared for the interview, you shouldn't break any taboos.

BTW, good luck in the interview.

I talked to the recruiter and they stated that I must code the answer to find a numerical value. Do you have any ideas what they mean?
 
Robben said:
I talked to the recruiter and they stated that I must code the answer to find a numerical value. Do you have any ideas what they mean?
It sounds like you will be given a value as a String or some other non-numerical format and will be expected to return the numerical value. There could be any number of ways to code that depending on the problem that they give you. For example, could you code the following cases?
  • Write a program that takes a String input from a user and outputs the value as a number. Pretty simple and straightforward - you probably won't get this lucky. :oldtongue:
  • Or, the above problem where the user can input letters and numbers and you have to find the numbers within - For example, given the input "fosi7f2h98s", your program should output 7, 2, 98 (or 7, 2, 9, 8 depending on how they ask for it).
  • Given an input string of the following formats, write a program that calculates the answer - For example, "4 + 2", "12 / 3", or "2*6". Note that some have spaces and some do not.
  • Or, the above problem with multiple operations taking into account operator preference - For example, "4+2*6/2-3". You would have to look ahead to make sure that the next operator(s) don't take precedence over the current one such that you don't add 4 to the 2 before multiplying it by 6 and then dividing it by 2.
  • And, probably worst of all, given an input of the form "4plus2times6divided by2minus3", find the answer.
 
Last edited:
Borg said:
It sounds like you will be given a value as a String or some other non-numerical format and will be expected to return the numerical value. There could be any number of ways to code that depending on the problem that they give you. For example, could you code the following cases?
  • Write a program that takes a String input from a user and outputs the value as a number. Pretty simple and straightforward - you probably won't get this lucky. :oldtongue:
  • Or, the above problem where the user can input letters and numbers and you have to find the numbers within - For example, given the input "fosi7f2h98s", your program should output 7, 2, 98 (or 7, 2, 9, 8 depending on how they ask for it).
  • Given an input string of the following formats, write a program that calculates the answer - For example, "4 + 2", "12 / 3", or "2*6". Note that some have spaces and some do not.
  • Or, the above problem with multiple operations taking into account operator preference - For example, "4+2*6/2-3". You would have to look ahead to make sure that the next operator(s) don't take precedence over the current one such that you don't add 4 to the 2 before multiplying it by 6 and then dividing it by 2.
  • And, probably worst of all, given an input of the form "4plus2times6divided by2minus3", find the answer.

Oh, I see. Sounds reasonable.

For your first example, do you mean a String that contains only integers i.e. "123" then I must convert the string into an integer?

And the last two examples looks pretty difficult. I am going to attempt them now. Thanks a bunch!
 
Robben said:
For your first example, do you mean a String that contains only integers i.e. "123" then I must convert the string into an integer?
Yes. It's unlikely that they would ask for something this easy unless they want you to include proper error handling also. Error handling in this case would probably be to recognize that it isn't a proper number and ask the user to try again (or enter 'q' to quit). Of course you should try to implement error handling in whatever you code for the test.
 
  • Like
Likes Robben
Borg said:
Yes. It's unlikely that they would ask for something this easy unless they want you to include proper error handling also. Error handling in this case would probably be to recognize that it isn't a proper number and ask the user to try again (or enter 'q' to quit). Of course you should try to implement error handling in whatever you code for the test.
By error handling would an if and else statement suffice or would I have to use a try and catch block?
 
  • #10
Robben said:
By error handling would an if and else statement suffice or would I have to use a try and catch block?
For that example, I would put a try catch block within a loop. Something like this:
Java:
Integer finalValue = null;
boolean validValue = false;
while(!validValue) {
    try {
        // Get user input
        // Check for 'q' and quit if that's the case
        // Otherwise attempt to convert input to int
        // If it doesn't throw an error...
        validValue = true;
    }
    catch(Exception e){
        // Display error message
    } 
}
// Display output
 
  • Like
Likes Robben
  • #11
Thank you very much!
 
  • Like
Likes Borg
Back
Top