Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Junior Java Interview Questions -- What to Expect?

  1. May 6, 2015 #1
    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?
     
  2. jcsd
  3. May 6, 2015 #2

    Borg

    User Avatar
    Science Advisor
    Gold Member

    Have you tried asking the recruiter?
     
  4. May 6, 2015 #3
    I thought it would have been bad/taboo to ask the recruiter lol? So it is acceptable to ask the recruiter?
     
  5. May 6, 2015 #4

    Borg

    User Avatar
    Science Advisor
    Gold Member

    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.
     
  6. May 7, 2015 #5
    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?
     
  7. May 7, 2015 #6

    Borg

    User Avatar
    Science Advisor
    Gold Member

    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: May 7, 2015
  8. May 7, 2015 #7
    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!
     
  9. May 7, 2015 #8

    Borg

    User Avatar
    Science Advisor
    Gold Member

    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.
     
  10. May 7, 2015 #9
    By error handling would an if and else statement suffice or would I have to use a try and catch block?
     
  11. May 7, 2015 #10

    Borg

    User Avatar
    Science Advisor
    Gold Member

    For that example, I would put a try catch block within a loop. Something like this:
    Code (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
     
     
  12. May 7, 2015 #11
    Thank you very much!
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Junior Java Interview Questions -- What to Expect?
  1. Java Question (Replies: 2)

  2. Java question (Replies: 5)

  3. Java Question (Replies: 2)

  4. Java Question (Replies: 3)

Loading...