Comprehensive Study Guide on Computer Programming and Java Fundamentals
Fundamentals of Computer Programming
- Computer Program: A set of step-by-step instructions written in a programming language that tells a computer what tasks to perform.
- Program: Tells a computer what to do in order to come up with a solution to a particular problem.
- Programming Language: A standardized communication technique for expressing instructions to a computer.
- Core Aspects of Programming Languages:
- Syntax: The rules and structure of code. Defines how statements in a language must be written.
- Semantics: The meaning and behavior of code.
- Pragmatics: The writing style and readability of code.
Levels of Programming Languages
- Machine Language:
- The computer's native language.
- Consists of a set of built-in primitive instructions written in binary code.
- Machine dependent.
- Assembly Language:
- Referred to as a low-level language.
- Uses short descriptive words, known as mnemonics, to represent each machine-language instruction.
- Developed to make programming easier than raw machine language.
- High-Level Language:
- Written in English-like codes, making it easy to learn and use.
- Code written in a high-level language is called a source program or source code.
- Platform independent.
- Examples include Java, C, C++, Basic, and Fortran.
Key Computer Science Terminologies
- Source Code: The human-readable instructions written by a programmer (e.g., a
.java file). - Compiler: A program that translates source code into a form the machine can execute (e.g., bytecode for Java).
- Interpreter: A program that executes source code (or bytecode) line by line, rather than translating the whole program at once.
- Syntax: The set of rules that defines how statements in a language must be written.
- Algorithm: A step-by-step, ordered procedure for solving a problem, independent of any specific programming language.
- Bug: An error in a program.
- Debugging: The process of finding and fixing errors within a program.
Overview of the Java Programming Language
- Core Characteristics:
- A high-level, object-oriented programming language.
- Portable: Adheres to the principle "Write Once, Run Anywhere" (WORA).
- Secure, robust, and versatile.
- Applications and Industry Relevance:
- Used extensively in web, mobile, enterprise, and embedded systems.
- Powers Android development.
- Trusted by major organizations and companies, including banks and tech firms.
History and Milestones of Java
- 1991 (Early Years): Sun Microsystems forms the Green Team Project, a small group of engineers led by James Gosling. Gosling begins work on the Oak programming language, which would later be renamed Java.
- 1995 (Birth & Debut): Java makes its official debut, and the Oak programming language is renamed Java.
- 1998: Visa launches the world's first smart card based on Java Card technology.
- 1999 (Redefined Architecture): Sun announces a redefined architecture for the Java platform, introducing the Java 2 Platform split into three distinct editions: Java 2 Platform Standard Edition (J2SE), Java 2 Platform Enterprise Edition (J2EE), and Java 2 Platform Micro Edition (J2ME).
- 2000 (Mac Adoption): Apple Co-Founder and Chief Executive Steve Jobs announces that Apple would bundle Java 2 SE with every version of its new Mac OS X operating system.
- 2003: Java's new coffee cup logo debuts alongside its mascot, Duke.
- 2006 (Open Source Transition): Sun releases Java Platform Standard Edition (Java SE), Enterprise Edition (Java EE), and Micro Edition (Java ME) to open-source development under the GNU (General Public License).
- 2009: Oracle acquires Sun Microsystems.
- 2015: Java celebrates its 20th anniversary.
- Java SE (Standard Edition):
- Formerly known as J2SE.
- Designed for standard desktop and workstation applications.
- Contains core language features and libraries; forms the central focus of core Java courses.
- Java EE (Enterprise Edition):
- Formerly known as J2EE.
- Tailored for heavy-duty server systems and large-scale, distributed, web-based applications.
- Java ME (Micro Edition):
- Formerly known as J2ME.
- Built for small, memory-constrained devices and resource-constrained devices such as embedded systems (Deitel & Deitel, 2012).
Execution Workflow and the Four Phases of a Java Program
- Overall Execution Workflow:
- Write: Code is written in an editor as a
.java file containing the class name. - Compile: The Java compiler (
javac) compiles the .java source code into a .class file containing Java bytecode. - Run: The interpreter / Java Virtual Machine (JVM) loads, verifies, and executes the bytecode to generate output.
- The 4 Detailed Phases to Produce Output:
- Edit: Write the source code in a
.java file using a text editor. - Compile: Translate the source code into bytecode (stored in a
.class file) using the javac compiler. - Load / Verify: The Java Virtual Machine (JVM) loads the
.class file into memory and verifies it for safety. - Run: The JVM executes the bytecodes, interpreting it directly or compiling parts of it using just-in-time (JIT) compilation to produce final output.