The Java interview questions you should not ask in 2022

Recently I wrote an article on What are the most important skills as a Java Software Engineer?

I’ve got a really funny reaction for that post from a fellow Software Engineer, let me share.

There was this section in the article called Skills recruiters are looking for and I estimated that if recruiters look at your CV and they find a 75% match between the job description and your CV, they’ll most likely call you. Fellow engineer:

  • Linkedin profile says Java
  • Recruiter: “according to your profile you may be a good fit for a JavaScript opportunity I have”

All I’ve got to say, it’s accurate as hell. Maybe I overestimated with that 75%. Dear Recruiters, please learn the difference between Java and JavaScript. It’s embarassing having to deal with this in 2021/2022.

Anyway, I wanted to grab this opportunity to continue on this topic a bit more and talk about some specifics. In this article, I’ll give you a couple of interview questions you generally shouldn’t ask on a Java interview in 2022.

Roasting interview questions

Okay, let’s jump into the questions. I googled “Java interview questions” and I picked some of them to talk about (top 3-4 google hits). And please note, I’m simply going to consider the candidate being above junior level. Obivously it’s a whole different topic when interviewing junior candidates.

Why is Java a platform independent language?

Hmm. I had to think through how to put it delicately but come on. Is this really a question on an interview nowadays?

When the web was still a toddler, there were a lot of thick/fat clients. If you don’t know what a thick client is, that’s my point. Before React, Micronaut, and the early days of Spring there were desktop applications written using Swing, a Java UI framework. Then JavaFX came along to upgrade it but I bet you haven’t seen a thick Java client lately (or ever for that matter).

Platform independence doesn’t really make sense anymore as a feature for Java. Why? Because most of the Java applications are backend apps and and we run literally everything in docker. And guess what, I know some of you are working in the financial industry where the transition to new applications is much slower and you might still use some Swing/JavaFX/Eclipse RCP based thick client but you’re definitely going to move away from it.

And one last funny thing. Did you try to run a Swing app back in the days on multiple platforms? Bad news my friend, it wasn’t necessarily platform independent cause features not or not that accurately were implemented for all common platforms.

That’s why this question doesn’t make sense. Especially if you consider the fact that you’re not talking to a junior candidate.

Explain public static void main(String args[]) in Java

Huge questionmark for me. What the hell are we trying to find out about the candidate? That he has never ran a Java app?

Again, if you’re not talking to a complete junior who has just started with the language and programming, you won’t get anything valueable from this answer however you can waste your precious interview time.

What are constructors in Java?

I’m not sure how to react to this one. Unless the candidate just started with Java and programming, the answer will be correct.

What is the difference between Array list and vector in Java?

Please put your hands up if you touched a Vector in the last 3 years. I personally haven’t used a Vector during my entire carreer. Even in 2010 it was recommended by Sun/Oracle to use an ArrayList.

So what’s the point of this question? If the candidate knows the full history of Java back to the ’90s?

There’s no reason to ask this.

A good discussion point might be to talk about the differences between an ArrayList and a CopyOnWriteArrayList to see if the candidate knows what are the issues with the regular ArrayList and what is the common data structure to replace it for a multithreaded environment, but again; this is so specific to a job, generally I’d advise not to ask it.

How is an infinite loop declared in Java?

Why, why why? I literally don’t get the reason behind this question. Why on Earth are you interested in whether the candidate is able to write an infinite loop.

Is it because you think if the candidate can write an infinite loop intentionally, she/he can avoid it during a real project?

Trust me, an infinite loop doesn’t look like this on a real project.

while (true) {
    // do stuff
}

Briefly explain the concept of constructor overloading

Ehm, what? For somebody having a tiny bit of xp, this is gonna be an automatic answer yet you didn’t get to know anything about how the person thinks.

What are the differences between C++ and Java?

Huge questionmark I guess. You could even ask what are the differences between Java and JavaScript. Testing lexical knowledge is bad, bad, bad. Plus why should a Java engineer know the specifics of C++?

List the features of Java Programming language.

I’ll go through the answers the author gave to this question:

Simple

What a feature, right?

Object-Oriented

True, but is it really considered as a feature? Especially that OOP means so much more than just creating classes and interfaces.

Portable

The explanation says that the language is portable because it can run on multiple platforms. This is definitely true but I’m really unsure if somebody would think of this as a “feature”.

Platform Independent

What’s the difference between this and Portable? Even the author gives the same answer.

And there are many more items on the list just as silly as these are.

I beg you, don’t ask this question.

How many types of memory areas are allocated by JVM?

This could be a good question but I’d rephrase a bit: “Tell me about the memory management in the JVM”. However, I’d quote myself again. This question is specific to certain applications and jobs. If you’re developing a regular web app with Spring or whatever framework, you most probably don’t need to know how memory management works. And you can fight me on this but I truly believe we choose people for the job. Nobody can learn and know everything.

Do you know how to drive a car? Do you know what main parts are there in the car? Do you know how the engine is connected to the exhaust and stuff? I guess you can answer the first 2 questions, but the third one you can’t. Similar stuff here. If you’re gonna be a car mechanic then yeah, you should know that too, otherwise nope.

Back to the original question. Apparently the answer is:

  • Class(Method) Area
  • Heap
  • Stack
  • Program Counter Register
  • Native Method Stack

The last 2 I’ve never even heard of throughout my carreer. Perhaps this is qualifying me as somebody ignorant to learning this stuff in detail but have you ever talked about the Program Counter Register or the Native Method Stack with a fellow developer? Have you ever needed to be aware of those 2 things?

Personally over the last 10 years, I’ve never ever touched or was aware of those.

Is Empty .java file name a valid source file name?

Dude, if this comes up on an interview and you’re the candidate. Run from that company. You’ll be better off, trust me.

Is delete, next, main, exit or null keyword in java?

What in the hell? Are you gonna ask the questions from the JLS (Java Language Specification)?

How to install Java?

Oh my gosh. This must be a joke.

How to take input in Java?

Somebody learning about Java would start with taking some input from the console but come on. Let’s be realistic here. This won’t come up during most of the projects.

There’s literally no reason to ask this because you’re not going to validate anything. Do you want the candidate to code a Scanner usage right in front of you? I undertake that I wouldn’t be able to do so because I haven’t used the Scanner interface in like an eternity. Last time I remember was during my university years.

Don’t ask the question.

How to set path in Java?

Complete non-sense. How the hell is this related to Java. The answer according to the question author is to explain how to set the PATH environment variable on Windows, Mac and Linux and Solaris.

Like what the hell dude?

Summary

When I started collecting the questions from the top Google hits, I turned pale. I cannot believe these are actual questions and I only covered just a couple of them.

Maybe I should make a series and roast more of them. We’ll see.

Anyway, if you wanna take away something from the article, here’s the essence:

  • Don’t ask these questions
  • Try focusing more on how the person thinks rather than testing lexical knowledge

Hope you liked it, follow me on Facebook/Twitter if you want to and share it with others in the hope of stopping the madness of asking these questions.

One Reply to “The Java interview questions you should not ask in 2022”

  1. Michel says:

Leave a Reply

Your email address will not be published. Required fields are marked *