Introduction to Computers, Programs, and Java

Computer Hardware Architecture

A computer consists of major hardware components connected through a central communication subsystem known as the bus.


Hardware components connected via a central bus
  • Input Devices: Capture external input (e.g., Keyboard, Mouse).

  • Output Devices: Display or output results (e.g., Monitor, Printer).

  • Communication Devices: Enable network interfacing.

    • Standard Modem: Transfers data up to 56,000bps56{,}000\,\text{bps} over phone lines.

    • Digital Subscriber Line (DSL): Operates 20 times faster than a standard modem.

    • Cable Modem: Utilizes cable TV infrastructure for speeds comparable to DSL.

    • Network Interface Card (NIC): Connects computers to a Local Area Network (LAN), such as 10BaseT operating at 10mbps10\,\text{mbps}.

Processor Evolution and Moore's Law

The Central Processing Unit (CPU) functions as the core brain of the computer, retrieving and executing instructions stored in memory.

  • Clock Speed: Measured in megahertz (MHz\text{MHz}) or gigahertz (GHz\text{GHz}), where 1MHz=1×106pulses/s1\,\text{MHz} = 1 \times 10^6\,\text{pulses/s} and 1GHz=1000MHz1\,\text{GHz} = 1000\,\text{MHz}.

  • Intel 4004 (1971): The first commercial 4-bit microprocessor operating at 740kHz740\,\text{kHz} (0.00074GHz0.00074\,\text{GHz}) with 2,300 transistors on a 10μm10\,\mu\text{m} process. It supported 4KB4\,\text{KB} of memory, used a 16-pin package, and operated at 15V15\,\text{V}.

  • Modern CPUs: 64-bit multi-core processors operating above 5GHz5\,\text{GHz} with billions of transistors on sub-10nm10\,\text{nm} processes, using voltages between 1.0V1.0\,\text{V} and 1.4V1.4\,\text{V}.

  • Evolutionary Milestones:

    • 4004 (1971): Single-chip programmable processor created for the Busicom calculator.

    • 8008/8080 (1972–1974): Transition to 8-bit architecture enabling personal computers.

    • 8086/8088 (1978): Introduced the x86 architecture.

    • Core Series (2006–Present): Multi-core, high-efficiency architectures.

  • Moore's Law: Formulated in 1965/1975 by Gordon Moore (co-founder of Fairchild Semiconductor and Intel), stating that transistor counts on integrated circuits double approximately every two years. David House suggested performance doubles every 18 months.


Moore's Law chart showing transistor count growth from 1970 to 2020

Data Storage and Memory

Memory (RAM) provides volatile, temporary storage for active program instructions and data.


Memory addresses and stored binary content
  • Byte Unit: A byte consists of 8 bits and serves as the minimum addressable storage unit.

  • Encoding Schemes: Data (numbers, characters, strings) are stored in binary form (00 and 11).

    • The character 'J' is encoded as 01001010.

    • Small numbers like 3 fit in a single byte (00000011), while larger numbers span contiguous adjacent bytes.

  • Data Volume Reference:

    • 1 page document: 20KB\approx 20\,\text{KB} (20,000bytes20{,}000\,\text{bytes})

    • 50 pages: 1MB\approx 1\,\text{MB} (1,000,000bytes1{,}000{,}000\,\text{bytes})

    • 50,000 pages: 1GB\approx 1\,\text{GB} (1,000,000,000bytes1{,}000{,}000{,}000\,\text{bytes})

  • Non-Volatile Storage: Permanent storage media include Magnetic Disks (hard disks, floppy disks), Optical Discs (CD, DVD), and USB flash drives.

Programming Languages and Translation

Programming languages allow developers to instruct computer hardware.

  • Machine Language: Native set of binary code instructions understood directly by the CPU (e.g., 1101101010011010).

  • Assembly Language: Uses short mnemonic instructions (e.g., ADD 2, 3, result) requiring an Assembler to convert code into machine instructions.

  • High-Level Languages: Human-readable languages (e.g., area = 5 * 5 * 3.1415;). Key examples include Ada, BASIC, C, C++, C#, COBOL, FORTRAN, Java, Pascal, Python, and Visual Basic.

  • Translation Methods:

    • Interpreter: Reads, translates, and executes source code line-by-line instantly at runtime.

    • Compiler: Translates the complete source program into a machine-code file prior to execution.


Compiler translating source code to machine code before execution

Operating Systems

The Operating System (OS) is essential system software managing and controlling all computer hardware and software resources.


Operating System position between user applications and hardware
  • Core Responsibilities:

    • Monitoring System Activities: Handles I/O operations, file systems, peripheral control, and system security.

    • Resource Allocation: Assigns hardware resources to active processes.

    • Task Scheduling: Coordinates execution via multiprogramming, multithreading, and multiprocessing.

Introduction to Java

Java is a general-purpose, platform-independent programming language designed for Internet and cross-platform application development.

  • Development History: Created in 1991 by Patrick Naughton and James Gosling at Sun Microsystems.

    • Originally named Oak for consumer devices like cable TV set-top boxes, then renamed Java.

    • In 1994–1995, Gosling built the HotJava browser to showcase web applet execution.

    • Adopted by Netscape Navigator in Fall 1995.

    • James Gosling received the ACM Software System Award in 2003.

  • Key Characteristics: Simple, Object-Oriented, Distributed, Interpreted, Robust, Secure, Architecture-Neutral, Portable, High Performance, Multithreaded, Dynamic.

  • JDK Editions:

    • Java SE (Standard Edition): Client-side desktop applications and applets.

    • Java EE (Enterprise Edition): Server-side web applications (Servlets, JavaServer Pages, JavaServer Faces).

    • Java ME (Micro Edition): Mobile and embedded applications.

Anatomy and Execution of a Java Program

Java programs utilize intermediate compilation and interpretation to achieve platform independence ("Write Once, Run Anywhere").


Java source code compilation into bytecode and JVM execution
  • Execution Process:

    1. Source code is written in a .java file.

    2. The compiler (javac) compiles source code into Java Bytecode saved in a .class file.

    3. The Java Virtual Machine (JVM) interpreter (java) executes bytecode on target operating systems (Windows, Solaris, macOS).

  • Program Components:

    • Class Definition: public class Welcome (class names begin with capital letters by convention).

    • Main Method: public static void main(String[] args) serves as the required entry point for program execution.

    • Statements & Terminator: Program instructions end with a semicolon ;.

    • Reserved Words: Words with predefined compiler meanings (class, public, static, void).

    • Blocks: Code groups enclosed within curly braces {}.

Programming Style Guidelines

Maintaining consistent coding conventions improves readability and maintainability.

  • Special Symbols Summary:

    • {} : Encloses statement blocks.

    • () : Used in method parameters and control structures.

    • [] : Declares and accesses arrays.

    • // : Denotes single-line comments.

    • "" : Encloses string literal values.

    • ; : Terminates individual statements.

  • Style Conventions:

    • Program Header: Include author details, date, course, section, and a summary description.

    • Naming Rules: Use UpperCamelCase for class names (e.g., ComputeExpression).

    • Indentation & Spacing: Indent two spaces per block level; use blank lines between logical sections.

    • Brace Style: Standard Java practice uses end-of-line style opening braces.

Programming Errors

Program errors fall into three main categories:

  • Syntax Errors: Violations of language structure detected during compilation (e.g., unclosed string literals or missing semicolons).

  • Runtime Errors: Unanticipated conditions causing program termination during execution (e.g., division by zero 1/01 / 0).

  • Logic Errors: Errors where the program completes execution without crashing but produces incorrect results (e.g., evaluating (95)×35+32\left(\frac{9}{5}\right) \times 35 + 32 using integer division 9 / 5, which truncates to 1).