Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2016
    Posts
    93
    Rep Power
    0

    Default Preparing for job interview questions

    Flash cards and technical terminology go great together, but what about conceptual questions that will likely be asked in a job interview for a Java Programming job? That's what this thread is for.

    First question. In the following setter method:
    Java Code:
    public void setQuantity(int Qty){
    		quantity = Qty;
    	}
    Why is the Qty on the right-hand side of the assignment operator? Is quantity being assigned to the Qty variable, or is it the other way around? What does "assigned to" mean exactly? What is happening when one variable name is being assigned to another variable name?

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    14

    Default Re: Preparing for job interview questions

    Think about algebra. x = 10; It comes from the math field. x is assigned the value of 10. Of course, x = x + 1 is not mathematical.
    It means x is replaced by the current value of x plus 1.

    Internally, think of Qty and quantity as labels for memory locations. So assignments simply copy a value from one location to
    another.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Join Date
    Mar 2016
    Posts
    93
    Rep Power
    0

    Default Re: Preparing for job interview questions

    Quote Originally Posted by jim829 View Post
    Internally, think of Qty and quantity as labels for memory locations. So assignments simply copy a value from one location to
    another.
    A basic move instruction in assembly language syntax can be written in one of two ways:
    https://en.wikipedia.org/wiki/X86_as...anguage#Syntax

    So in the Java statement:
    Java Code:
    quantity = Qty;
    Which is the destination, and which is the source?

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default Re: Preparing for job interview questions

    In all Algol/C etc. like languages, the assignment expression 'a= b' means that the value of expression 'b' is assigned to expression 'a'. The value of the entire expression is the new value of expression 'a'.

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: Preparing for job interview questions

    Is anyone actually asked this in an interview for a Java job?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    Join Date
    Mar 2016
    Posts
    93
    Rep Power
    0

    Default Re: Preparing for job interview questions

    True or false:

    Implicit casting only uses widening conversion, while explicit casting only uses narrowing conversion?

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default Re: Preparing for job interview questions

    False, have a look at this explicit cast:

    Java Code:
    byte b= 42;
    int i= (int)b; // explicit widening cast
    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Interview questions
    By Rajaa in forum New To Java
    Replies: 3
    Last Post: 05-11-2011, 07:54 AM
  2. Java Interview Questions
    By lakshmiv92 in forum Jobs Discussion
    Replies: 0
    Last Post: 10-19-2010, 08:59 AM
  3. questions b4 Job interview
    By dardar in forum New To Java
    Replies: 3
    Last Post: 09-19-2010, 12:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •