# Thread: Preparing for job interview questions

1. Member
Join Date
Mar 2016
Posts
93
Rep Power
0

## 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. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
6,226
Rep Power
14

## 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

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

## Re: Preparing for job interview questions

Originally Posted by jim829
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. ## 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

5. Moderator
Join Date
Apr 2009
Posts
13,541
Rep Power
27

## Re: Preparing for job interview questions

Is anyone actually asked this in an interview for a Java job?

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

## Re: Preparing for job interview questions

True or false:

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

7. ## 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

#### Posting Permissions

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