ADVENTURE ISLAND AT GOOGLE AS SANKALP SE SIDDHI BHARAT.

ADVENTURE ISLAND AT GOOGLE AS SANKALP SE SIDDHI BHARAT.
DR. PRERNA SAXENA IT WOMEN SCIENTIST AT GOOGLE

Thursday, December 4, 2025

SUN JAVA BASICS

The term "Sun Java Basics" refers to the fundamental concepts of the Java programming language, as it was originally developed by Sun Microsystems (before being acquired by Oracle).

Here is an overview of the core concepts that define Java's foundation:

📜 Core Principles and Structure

1. The Java Platform

The Java platform is what makes Java applications highly portable ("Write Once, Run Anywhere").

  • Java Virtual Machine (JVM): The abstract machine that executes Java bytecode. It's the interpreter layer that translates bytecode into the native machine code of the underlying OS (Windows, macOS, Linux).

  • Java Runtime Environment (JRE): The minimal software required to run a Java application. It includes the JVM, core classes, and supporting files.

  • Java Development Kit (JDK): The full set of tools for developing Java applications. It includes the JRE, the compiler (javac), and other debugging/utility tools.

2. Execution Flow

  1. You write source code in a .java file.

  2. The Compiler (javac) converts the source code into bytecode in a .class file.

  3. The JVM executes the bytecode.

  4. Shutterstock
    Explore

💡 Syntax and Language Fundamentals

1. Basic Structure

All executable Java code must be contained within a class. Execution begins in the main method.

Java
public class MyFirstProgram {
    public static void main(String[] args) {
        // Output statement
        System.out.println("Hello from Java!"); 
    }
}

2. Data Types

Java has two main categories of data types:

CategoryTypeDescriptionExample
Primitiveint, long, float, doubleNumeric values (integers and decimals).int count = 10;
charA single Unicode character.char initial = 'S';
booleanRepresents true or false.boolean isComplete = true;
Non-PrimitiveString, Arrays, ClassesReference types that hold memory addresses.String name = "Sun";

3. Variables

Variables must be declared with their type before they can be used.

  • Declaration: int speed;

  • Initialization: speed = 60; or combined: int speed = 60;

  • Constants: Defined using the final keyword (e.g., final double PI = 3.14159;).

4. Operators

  • Arithmetic: +, -, *, /, % (modulo/remainder).

  • Relational: ==, !=, >, <, >=, <=.

  • Logical: && (AND), || (OR), ! (NOT).


🔁 Control Flow

These constructs determine the order in which statements are executed.

1. Decision Making

  • if-else: Executes a block if a condition is true.

    Java
    if (score >= 90) {
        System.out.println("Grade A");
    } else {
        System.out.println("Not an A");
    }
    
  • switch: Executes one block of code among many alternatives based on a single value.

2. Looping

  • for loop: Used when you know the number of iterations beforehand.

    Java
    for (int i = 0; i < 5; i++) {
        System.out.println(i); // Prints 0 to 4
    }
    
  • while loop: Repeats a block of code as long as a condition is true.

  • do-while loop: Executes the loop body at least once, then checks the condition.


⚙️ Object-Oriented Programming (OOP)

Java is an OOP language, built around the concept of objects and classes.

  • Class: A blueprint for an object. It defines the structure (data/variables) and behavior (methods/functions) of its objects.

  • Object: An instance of a class. When you create an object, memory is allocated for it.

The four pillars of OOP are:

  1. Encapsulation: The mechanism of binding the data (variables) and the code acting on the data (methods) together into a single unit (the class), and protecting the data from outside interference.

  2. Inheritance: The process by which one class acquires the properties and methods of another class, promoting code reuse.

  3. Polymorphism: The ability of an object to take on many forms. This is achieved through method overriding (redefining an inherited method) and method overloading (methods with the same name but different parameters).

  4. Abstraction: Hiding complex implementation details and showing only essential information. This is achieved using abstract classes and interfaces.

Would you like to explore more about OOP concepts or see an example of control flow?