Java Foundations· 25 min

Java Program Structure and Types

Understand source files, bytecode, the entry point, primitive types, references, and Java's compile/run cycle.

Java interview lesson
Question 1 · Not reviewed

Foundations · language model

Can you explain this clearly in an interview?

Use the strong answer as your reference, explain it aloud in your own words, then choose how soon you want to review it again.

Interview prompt

Java Program Structure and Types

Explain it aloud in your own words

Strong answer

Java source is compiled by javac into platform-independent bytecode. The JVM loads, verifies, and executes that bytecode, while the JIT compiler optimizes hot code at runtime. Primitive values hold data directly; reference variables point to objects managed on the heap.

Key points

  • Java is statically typed and class-based.
  • A reference is not the object itself; it can be null.
  • The main method is only the conventional application entry point.
  • Compile-time type checking and runtime polymorphism solve different problems.

Interviewer looks for

A strong answer connects source code, bytecode, JVM execution, primitive/reference semantics, and compile-time versus runtime behavior.

Java example

1int count = 3;
2String name = new String("Ada");
3System.out.println(count + " - " + name);

Topic interview questions

Revise this topic like an interviewer

These questions are tied to this lesson. Read each question aloud, then compare your explanation with the strong answer.

5 questions
Q1Intermediate

What happens between compiling a Java file and running it?

Strong answer

javac compiles source into bytecode in a class file. The JVM loads, verifies, links, initializes, and executes that bytecode, with the JIT compiling frequently executed paths to native code.

Q2Basic

What is the difference between the JDK, JRE, and JVM?

Strong answer

The JVM executes bytecode, the JRE packages the JVM with runtime libraries, and the JDK includes the JRE plus development tools such as javac, javadoc, and jdb.

Q3Intermediate

How are primitive variables different from reference variables?

Strong answer

A primitive variable holds a value such as an int or boolean directly. A reference variable holds a reference to an object and can also contain null; the object itself is managed on the heap.

Q4Intermediate

Why is public static void main(String[] args) used as the entry point?

Strong answer

public makes it accessible to the launcher, static lets the JVM call it without creating an object, void means it returns no value, and String[] args receives command-line arguments. The launcher convention is not the only possible Java method signature.

Q5Intermediate

What is the difference between compile-time type checking and runtime polymorphism?

Strong answer

The compiler checks whether an expression is valid using its declared type. At runtime, an overridden instance method is selected using the object's actual type, which enables polymorphism.

How well do you know this?

Your review choice is saved locally and synced to your learner profile when signed in.