What is Java? — Java Technical Interview Questions & Answers
What is Java?
What is Java?
- Java is a language for writing programs. You type instructions in a .java file, the same way you write steps in a notebook. The computer follows those steps and shows a result — print a line, save a mark, or run a website backend. If you can explain that in one breath, you already know what Java is. Don’t start with “object-oriented high-level buzzwords”. Start with: we write instructions, Java runs them.
- The idea that actually matters for a fresher: write the program once. The same program can run on Windows at home, Linux in college, or a company server. You do not rewrite it for each computer. That is why people still hire Java for banks and office software. C++ often builds one program for one operating system. Java builds bytecode for the JVM, and the JVM sits on many machines.
- How does that work, slowly? You write Main.java. You compile with javac. Java makes Main.class. That file is bytecode — not a Windows .exe, not a Linux binary. Any machine with a JVM can run it: java Main. People call this write once, run anywhere. “Anywhere” still needs a JVM installed. It does not mean zero install.
- Let’s do this on the board. Smallest program: a class named Main, a method named main, and System.out.println("Hello Java");. Save the file as Main.java — same name, same spelling, same capital M. Compile: javac Main.java. Run: java Main. If you see Hello Java, your JDK is working. If you see a scary error, check the file name first. Freshers lose an hour on Main vs main.java.
- Almost all Java code is split into classes and objects. Think of Student or BankAccount. Marks and deposit() live together, not as 50 loose variables. That is why Java feels like “real world things”, not only maths. You will learn class properly in the next chapters. For now, remember: class is the blueprint, object is one real student made with new.
- Install JDK on your laptop, not only JRE. JRE can run a ready program. JDK lets you compile with javac. After install, open a new terminal and type java -version and javac -version. If javac is missing, PATH is wrong or you installed JRE only. This is a lab/viva question, not a waste of time.
- Learn in this order so you don’t get lost: variables and data types → if and loops → class and object → errors (try/catch) → lists (ArrayList) → threads later. If you jump to Spring on day two, you will only copy code. If you can write Hello Java, even/odd, and a tiny Student class, you are actually learning Java.
Main.java
│ javac
▼
Main.class (bytecode)
│ java
▼
JVM
│
├── Windows
├── Linux
└── Mac
▼
Hello JavaTechnical Interview Tip: Say: same program runs on many machines because of JVM. Then name one use, like a bank server.
Code Examples for What is Java?
Example
// Start with Java
public class Main {
public static void main(String[] args) {
System.out.println("Hello Java");
}
}What is Java? — output: Hello Java. javac Main.java then java Main. If this prints, JDK path is fine.
How to Explain What is Java? to an Interviewer
What is Java?
A language to write programs Same code can run on many computers Uses classes and objects
What is bytecode?
.class file after javac Not a Windows .exe JVM can run it anywhere
What is JVM?
Java Virtual Machine Runs bytecode This is why Java is portable
Why do we need JDK?
To compile code (javac) JRE/JVM alone is mostly for running Check with javac -version
Where is Java used?
Bank / office software Backend servers Many Android (older) apps