What is a Computer?
1.1 What is a Computer?
๐งญ Overview
๐ง One-sentence thesis
Computers are programmable electronic devices that enable users to store, retrieve, and process data through instructions written in programming languages like Java.
๐ Key points (3โ5)
- What a computer is: an electronic, programmable device for storing, retrieving, and processing information.
- What programming does: translates human-written code into instructions that computers can execute to perform specific tasks.
- Java's role: a popular, platform-independent programming language introduced in 1995 that works across different operating systems.
- Source code basics: the .java file containing programming statements that compilers transform into executable output.
- Common confusion: class name vs. file nameโin Java, the source code file name must match the class name (e.g., "SampleClass" โ "SampleClass.java").
๐ป Understanding computers and programming
๐ป What a computer does
A computer is an electronic and programmable device that allows users to store, retrieve, and process information and data.
- The excerpt emphasizes three core capabilities: store, retrieve, and process.
- "Programmable" means the computer can be given different instructions to perform different tasks.
- Computers execute mathematical calculations and logical computations when given appropriate instructions.
๐ What computer programming is
Computer Programming is a process of writing code that can translate into instructions for a computer system.
- Programming allows programmers to write a set of instructions to perform specific tasks.
- It acts as a translation layer: human-readable code โ computer-executable instructions.
- Many programming languages exist (Java, C, C++, C#, Python); different programmers prefer different languages.
โ Java programming language
โ What Java is
- Java is described as a "popular computer programming language."
- Platform-independent: works across almost all operating systems (Windows, Linux, OSX, etc.).
- First introduced in 1995 by Sun Microsystems.
- Has evolved since introduction; many modern applications are developed using Java.
๐ Source code and file naming
Programming statements are also known as source code. In Java, programming source code means the .java file where programmers write and save their programming statements.
- Source code = the .java file containing programming statements.
- Compilers use source code to generate object codes or output files.
- Critical rule: the class name and the source code file name must be the same.
- Example: a class named "SampleClass" must be saved as "SampleClass.java."
๐ง Basic Java program structure
๐ง Key components
The excerpt walks through a simple Java program with these elements:
| Component | What it does | Line reference |
|---|---|---|
| Class declaration | Defines the class name and opens with { | Line 1 |
| Main method | Entry point where program execution begins | Lines 2-5 |
| Print statement | Built-in function to display messages on screen | Line 4 |
| Closing brace | Ends the class definition with } | Line 6 |
๐ฌ Comments in code
- Single-line comments use
//โ anything after//is ignored by the compiler. - Programmers use comments to explain code without affecting execution.
- Multi-line comments use
/* ... */(called "block comments"). - Example from excerpt:
// print "Hello Class!!" on the screen when this program runs
๐จ๏ธ Output mechanism
System.out.println();is the built-in function to display output.- Whatever appears within the double quotes
""will be displayed on the screen. - Example:
System.out.println("Hello Class!!");outputsHello Class!! - Don't confuse: the quotes are part of the syntax, not part of the output.