Java is maybe the most common backend language used in software engineering jobs. Amazon, Google, Netflix, Apple, and Twitter are all major tech companies that extensively use Java.
In this post I'll go over a couple of basic technical "weed out" questions you can ask Java developers.
Java is a language that strictly enforces and requires the programmer to understand and use OOP (Object Oriented Programming) principals.
Unfortunately many articles you will read on the internet will suggest asking these academic questions about Java.
Asking a candidate to name the 5 OOP concepts featured in Java (Object-Orientation, Inheritance, Encapsulation, Polymorphism, Abstraction) is pointless. It gives no indication that the candidate can do anything other than memorize words and definitions.
People love to ask these vocabulary questions in interviews and they suck. I think these are bullshit interview questions, and they don't shed any light on whether or not somebody has any skill or experience as a programmer.
If somebody asks me this in an interview it would probably give me pause because I think it has little evaluative quality and means the other people they hired before me may not be good engineers. Yes candidates are interviewing the company as well.
These questions below are less academic and more about programming and working in Java. They are also all pretty easy so if somebody messes these up it should be an actual red flag.
A fairly easy question. I'll list them out here. I would ask a candidate to name 3 or so, maybe not all of them...
for
loop. The basic for loop with an incrementing variable. for
each loop. A loop you can iterate over collections with. It uses the same for
keyword as the other for
loop. while
loopdo while
loopforEach
function on the collection interface, which is a more functional
style of programming but it does not use the for
keyword.Another question having to do with loops. The answer is simple and it should be difficult for a candidate to answer differently in a way that is correct. What I mean by that is that if they say anything else its probably wrong.
A "loop" is basically just a block of code that executes over and over based on some parameters. Break and continue just help you to control this.
The "static" keyword is a way to declare variables (declare means define, or to tell the program you want to make a variable). Variables are basic building block of programming languages used to store information a program will access.
Static means that for every copy you make of a class, it will always point back to the same value.
For example, let's say you create 5 copies of a class called "Breakfast" and it had a static variable called "bacon". That means the value of the bacon variable would the same for every Breakfast class.
Sorry if that example made you hungry, I happened to have bacon with breakfast this morning!
Another questions about a keyword you can use when declaring variables.
Final means that a variable once assigned, can never be reassigned. This means it can be considered a "constant" or a thing that be relied on to always have the same value once it is set. You can't change the value of the variable once it is set.
Note that you can use final in other places but this question is just about declaring variables.
Answer: They aren't. Java has a "garbage collector" which automatically manages memory for the programmer and there is no such thing as a pointer that a programmer can use in Java.
Pointers are a concept encountered in languages such as C
and C++
where programmers have access to memory locations directly.
This is a real world question, you want to understand how a candidate solves problems. They might answer with any of these things:
I would expect somebody to say #2
especially, since Java applications are notorious for running out of memory.
If you want to screen candidates for Java skill before you send them to a client, avoid the academic ones about OOP concepts. They don't indicate much of anything except that the candidate studied a list of crappy common Java interview questions on the internet.
Instead, its pretty easy to ask basic language concepts going over things like loops and keywords.