What is hard coding in Java?

First off, let’s clarify that hard coding is a term that applies to all programming languages and not just Java. So, what is hard coding? Well, it refers to the practice of using actual data values (as in actual numbers or strings like 3 or “abcd”) in the source code when instead what should be used are variables that accept any input value. There are definitely some situations when hard coding values may be necessary, but generally it is looked down upon as a negative practice that should be avoided whenever possible.

Why is it called hard coding?

The reason it is called hardcoding is because of the fact that the practice reduces the flexibility of the code by forcing actual values into the source code.

Hiring? Job Hunting? Post a JOB or your RESUME on our JOB BOARD >>

Subscribe to our newsletter for more free interview questions.

2 thoughts on “What is hard coding in Java?”

WordPress › Error

There has been a critical error on your website.

Learn more about debugging in WordPress.