0% found this document useful (0 votes)
7 views4 pages

Java Programming Basics and Structure

Java is a high-level, object-oriented programming language known for its platform independence and security, widely used for various applications. A typical Java program consists of a documentation section, package statement, import statements, class definition, and a main method. Key concepts include data types, operators, Java class libraries, and memory management, with a typical development environment involving an editor, compiler, and runtime environment.

Uploaded by

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

Java Programming Basics and Structure

Java is a high-level, object-oriented programming language known for its platform independence and security, widely used for various applications. A typical Java program consists of a documentation section, package statement, import statements, class definition, and a main method. Key concepts include data types, operators, Java class libraries, and memory management, with a typical development environment involving an editor, compiler, and runtime environment.

Uploaded by

timepassalltime0
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Definition of Java

Java is a high-level, object-oriented programming language developed by Sun


Microsystems (now Oracle). It is platform-independent (write once, run
anywhere), secure, and used widely for developing web, desktop, and mobile
applications.

🔷 2. Simple Java Program Structure

A typical Java program includes:

Section Description
Documentation Section Optional comments/docstrings
Package Statement Declares the package name
Import Statements Imports Java libraries or user-defined classes
Class Definition Defines the class
Main Method Entry point for the program

✅ Example:

java

/** This is a sample Java program */


package mypackage;

import [Link];

public class HelloWorld {


public static void main(String[] args) {
[Link]("Hello, World!");
}
}

🔷 3. Implementing Java Program

Steps:

1. Write code in .java file.


2. Compile using javac [Link].
3. Run using java ClassName.

🔷 4. JVM (Java Virtual Machine)

JVM is part of the JRE (Java Runtime Environment) that executes Java
bytecode. It ensures platform independence.

🔷 5. Data Types in Java

➤ Primitive Data Types

 byte, short, int, long (integers)


 float, double (floating point)
 char (character)
 boolean (true/false)

➤ Reference Data Types

 Objects, Arrays, Strings, Classes, Interfaces

✅ Example:

java

int a = 10;
double pi = 3.14;
boolean isJavaFun = true;
String name = "Java";

🔷 6. Floating Point Numbers

Used for decimal values.

java

float f = 5.75f; // needs 'f'


double d = 19.99; // default floating type

🔷 7. Operators and Expressions

Type Operators
Arithmetic +, -, *, /, %
Relational ==, !=, >, <, >=, <=
Logical &&, `
Assignment =, +=, -=, etc.
java

int a = 10, b = 5;
int c = a + b;
boolean result = (a > b) && (b > 2);

🔷 8. Java Class Libraries

Java provides built-in classes in packages like:

 [Link] (auto-imported)
 [Link] (Scanner, Date)
 [Link], [Link], etc.

java
import [Link]; // Import Scanner class

🔷 9. Typical Java Development Environment

Includes:

 Editor/IDE: Eclipse, IntelliJ, VS Code


 Compiler: javac
 Interpreter/Runner: java
 JDK/JRE/JVM: Java development and runtime environments

🔷 10. Memory Concepts

Java divides memory into:


 Stack: Method-level data (primitive types, references)
 Heap: Objects and dynamic memory
 Method Area: Class definitions and static variables
 PC Register & Native Method Stack

✅ Summary Table:

Concept Example/Syntax
Documentation /** Comment */
Package package mypack;
Import import [Link].*;
Class public class MyClass {}
Main Method public static void main(String[] args)
JVM Executes bytecode
Data Types int, float, String, etc.
Operators +, ==, &&
Libraries import [Link];
Memory Stack, Heap, Method Area

You might also like