0% found this document useful (0 votes)
9 views3 pages

13 Aug 2025 Java Program Structure

Uploaded by

lalit.du1917
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

13 Aug 2025 Java Program Structure

Uploaded by

lalit.du1917
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Java Program Structure (Diagram Notes)

Q. why static is used before main


method? Time: 09:30

// note: every keyword with capital initial


is class in java

🔑 Breakdown
1. class Test
 class → Reserved keyword (used to define class).
 Test → User-defined class name.
 { } → Curly braces (open & close define class block).

2. main Method Declaration


Statement: public static void main(String[] args)
 public → Access Modifier (accessible to all).
 static → No need to create object, directly accessible.
 void → Return type (returns nothing).
 main → Predefined method name (program entry point).
 (String[] args) → Parameter
o String → Data type
o [] → Array (square brackets)
o args → Argument name

3. Method Body
 { } → Curly braces (main method block).

4. Statement → System.out.println("Hello Java");


 System → Predefined class
 out → Static field of System class (object of PrintStream)
 println → Method of PrintStream class
 () → Parentheses (method call)
 "Hello Java" → String argument
 ; → Semicolon (statement terminator)

🔑 Additional Points (Not in your image but important)


 main() method signature can also be written as:
o public static void main(String args[])
o public static void main(String... args) (varargs).
 If main() is not public, JVM cannot call it → runtime error.
 If main() is not static, JVM cannot call it without creating an object.
 Without main(), program compiles but doesn’t run (NoSuchMethodError).
📌 Diagram Flow (Mindmap style):

1. What is a Variable?
 Variables are just a name to allocate a memory in RAM where we store the
data.
 Stored in: Random Access Memory (Primary Memory)
 Usage: Used during runtime (runtime area).
 Changeable: The value of a variable can change during program execution.

2. Need of Variables
 Example: int x = 4; int y = 5; int sum = x + y;
 Variable names (like x, y, sum) help in storing and retrieving values in memory.

3. Memory Representation (RAM)


 RAM (Random Access Memory): Stores variables during program execution.
 Example in diagram:
o Store values 4 and 5.
o Perform operations → result stored in another memory cell (sum = 9).

✅ Additional Points
1. Types of Variables in Java
o Local Variables: Declared inside a method, created when method is
called, destroyed when method ends.
o Instance Variables: Defined inside a class but outside methods, belongs
to objects.
o Static Variables: Declared with static keyword, common for all objects of
class.
2. Default Values (if not initialized):
int → 0
float → 0.0
o

boolean → false
o

String/Object → null
o
o

You might also like