Junior Java Interview Questions -- What to Expect?

In summary: 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.
  • #1
Robben
166
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
  • #2
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?
 
  • #3
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?
 
  • #4
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
  • #5
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?
 
  • #6
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:
  • #7
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!
 
  • #8
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
  • #9
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

Related to Junior Java Interview Questions -- What to Expect?

1. What is Java and why is it important for a junior developer to know?

Java is a widely used object-oriented programming language that is used for developing a variety of applications, such as web, mobile, and desktop applications. It is important for a junior developer to know Java because it is a fundamental language that is in high demand in the tech industry and is used in a wide range of fields.

2. What are the key concepts of Java that a junior developer should be familiar with?

A junior developer should be familiar with the key concepts of Java, including object-oriented programming, inheritance, encapsulation, polymorphism, and abstraction. They should also have a good understanding of data types, control structures, and exception handling.

3. How does Java differ from other programming languages?

Java differs from other programming languages in several ways. One major difference is that it is platform-independent, meaning that it can run on any operating system. It also uses a virtual machine, which allows for easier development and deployment of applications. Additionally, Java is strongly typed, which helps to prevent errors and improve code quality.

4. What are some common data types in Java?

Some common data types in Java include integers, floating-point numbers, characters, booleans, and strings. There are also more complex data types such as arrays, lists, and maps. It is important for a junior developer to understand how to use these data types and when to use them in their code.

5. How can a junior developer prepare for a Java interview?

To prepare for a Java interview, a junior developer should review the key concepts of Java and practice coding exercises to improve their skills. They should also familiarize themselves with common interview questions and be prepared to discuss their previous experience and projects. It is also helpful to research the company and the role to better understand what skills and knowledge may be required.

Similar threads

  • Programming and Computer Science
Replies
8
Views
1K
  • STEM Career Guidance
Replies
5
Views
1K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
27
Views
2K
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
14
Views
3K
  • Programming and Computer Science
Replies
6
Views
1K
Replies
1
Views
1K
  • Programming and Computer Science
4
Replies
107
Views
5K
  • Programming and Computer Science
Replies
3
Views
3K
Back
Top