Comprehensive Study Notes: CSEN2302 Programming I - Introduction to Java and Software Engineering

Computer Programming Fundamentals

  • Computer Programming: The technical process of designing, writing, testing, and maintaining the source code of computer programs.

  • Computer Program: A sequence of structured instructions written to perform a specified task on a computer. A computer cannot operate without functional programs.

  • Computer Software: A collection of computer programs that supply comprehensive instructions dictating computer operations. Programs are written using designated programming languages (e.g., C, Java). 4

  • Program Structure Elements:

    • Keywords: Predefined, reserved elements within a programming language. Keywords may only be used for their intended syntax purpose.

    • Defined Symbols: User-defined elements specified by the programmer. These act as symbolic names that reference memory variables.

    • Operators and Operands:

      • Operators: Functional symbols that execute mathematical or logical operations on one or more data elements.

      • Operands: The data elements or numbers acted upon by an operator.

      • Example: In the mathematical expression a+ba + b, the symbol ++ acts as the operator, while aa and bb represent the operands.

    • Syntax and Semantics: Structural rules governing program construction. Syntax specifies the precise required usage of keywords, operators, and symbols.

  • Programmer (Coder): An individual who utilizes programming languages to write software applications and computer programs.

Classification of Programming Languages

  • Low-Level Languages (LLL):

    • Architecturally close to computer hardware.

    • Executes directly on hardware without requiring external compilers or interpreters.

    • Machine Language: Binary system consisting entirely of 00s and 11s.

    • Assembly Language: Low-level symbolic code utilizing OPCODEs and MNEMONICS.

  • High-Level Languages (HLL):

    • Designed for human readability and user convenience; completely machine-independent.

    • Requires a compiler or interpreter to convert code into hardware-executable machine instructions.

    • Examples: Visual Basic, Pascal, Java, C, C++, and Python.

Program Execution Mechanics

  • Execution Role: Programming languages rely on dedicated Compilers or Interpreters to process code, execute commands, and compute output results.

  • Data Processing Workflow: Program processing receives user input, passes it through a Data Processing Unit (computer system), and generates resulting output.


Data Processing Unit execution process

Compilers and Interpreters

  • Compiler:

    • A program that translates high-level source code into low-level object code as a single complete unit prior to execution.

    • Translates human-understandable Source Code into machine-understandable Object Code saved in a separate file.

    • Compilation Process: Source Code →\rightarrow Compiler →\rightarrow Object Code →\rightarrow Execute Program.


Compilation execution flow from source code to object code
  • Interpreter:

    • A translation program that converts high-level instructions into low-level machine code dynamically at runtime.

    • Reads and executes source code line-by-line: sequentially translates line 1 and runs it, then translates line 2 and runs it, repeating continuously.


Interpretation execution loop

Software Engineering and Development Life Cycle

  • Software Engineering (SE): The professional discipline involved with specifying, designing, developing, and maintaining software applications using systematic technical methodologies.

  • Five Basic Phases of Software Development Life Cycle (SDLC):

    1. Requirement & Analysis: Defining software functional criteria and user requirements.

    2. System Design: Modeling system architecture, database structures, and software framework.

    3. Coding & Implementation: Writing the actual application code using specific programming languages.

    4. Integration & Testing: Combining system modules to perform quality assurance and verification.

    5. Deployment & Maintenance: Releasing application releases into operational environments and executing ongoing bug fixes.


Five phases of Software Development Life Cycle

Object-Oriented Programming (OOP) Paradigm

  • OOP Concept: A programming paradigm based on modeling software programs as collections of interacting objects, mimicking real-world entities (e.g., people, automobiles, buildings, papers) that possess state and perform actions.

  • Object-Oriented Terminology:

    • Class: A generic template, blueprint, or collection defining common attributes and behaviors for a category of entities.

    • Class Definition: Structural specification defining what properties its objects hold and what actions they execute.

    • Attributes: Defining characteristics, variables, and property data belonging to an object.

    • Object: A concrete instance created from a class template through instantiation.

      • Example: Car represents a general class; specific models like Ford Taurus, Chevrolet Camaro, and Ferrari represent individual object instances.

    • Method: A self-contained code module inside a class that carries out specific operations, analogous to procedures in functional languages.

  • Code Example Structure (Salary.java):

    • Source Code Implementation: java // EXAMPLE: Salary.java public class Salary { int basic; int travel; int health; void empSalary (int a, int b, int c) { System.out.println (a+b+c); } public static void main(String[] args) { Salary s = new Salary(); s.empSalary(2000, 500, 300); } }         

    • Program Output: 2800

    • Code Breakdown: Salary defines the class, s represents an instantiated object of class Salary, and main functions as the application execution entry point.

  • Three Pillars of OOP:

    • Encapsulation: Enclosing data fields and methods together inside a single class object entity while concealing internal operational implementation details from external code (Information Hiding).

    • Inheritance: The mechanism enabling new sub-classes to inherit shared properties and methods from existing super-classes while adding specialized features.

    • Polymorphism: Meaning "many forms"; allows a single method name or symbol to execute different computational behavior depending on context.

History and Evolution of Java

  • Origins: Developed in 1991 by a team at Sun Microsystems led by James Gosling. It was initially designed for programming smart home consumer appliances (such as washing machines and televisions).

  • First Public Release: Released publicly as Java 1.0 in 1995.

  • Syntax Foundations: Derives syntax structure from C and C++, while removing complex low-level pointer management features.

  • Five Primary Design Goals of Java:

    1. Simple, object-oriented, and familiar.

    2. Robust and secure.

    3. Architecture-neutral and portable.

    4. Executed with high performance.

    5. Interpreted, threaded, and dynamic.

  • Chronological Release History:

    • JDK 1.0: January 21, 1996

    • JDK 1.1: February 19, 1997

    • J2SE 1.2: December 8, 1998

    • J2SE 1.3: May 8, 2000

    • J2SE 1.4: February 6, 2002

    • J2SE 5.0: September 30, 2004

    • Java SE 6: December 11, 2006

    • Java SE 7: July 28, 2011

    • Java SE 8: March 18, 2014

    • Java SE 9: September 21, 2017

    • Java SE 10: March 2018

    • Java SE 11: September 2018

    • Java SE 12: March 2019

    • Java SE 13: September 2019

    • Java SE 14: March 2020

Java Architecture and Execution Environment

  • Write Once, Run Anywhere (WORA): Java is a general-purpose, object-oriented language designed with minimal platform dependencies, allowing compiled code to execute cross-platform without modification.

  • Java Bytecode: Java source files (.java) compile into an intermediate architecture-neutral code format called Bytecode (.class files), rather than direct hardware machine language.

  • Java Virtual Machine (JVM):

    • An execution engine written specifically for host computer platforms to interpret and execute bytecode instructions.

    • Performs security verification checks on bytecode before translating it into hardware-specific machine code (java.exe).

  • Execution Modes in JVM:

    • Interpreter: Converts and executes bytecode instructions line-by-line sequentially.

    • Just-In-Time (JIT) Compiler: Combines interpretation and compilation. Translates bytecode chunks into native machine code on-the-fly, producing significantly faster execution speeds than standard interpretation.

  • Platform Dependency Distinction:

    • Java Code and Bytecode are Platform Independent.

    • The JVM executable is Platform Dependent, as distinct JVM versions must be written specifically for each targeted Operating System.


Java source code compilation and JVM execution workflow