1/33
Flashcards covering key concepts from Chapter 1: computers, programs, programming languages, Java basics, program structure, syntax, errors, and programming style.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What are the main components of a computer as listed in the notes?
CPU, memory, storage (hard disk/floppy disk), input devices (keyboard, mouse), output devices (monitor, printer), communication devices (modem, NIC), and a system bus.
What is a computer program?
A set of instructions that tells a computer what to do; computers do not understand human languages; programs are written in programming languages.
What are the three broad categories of programming languages discussed?
Machine language, assembly language, and high-level language.
Machine language characteristics
Binary instructions built into the computer; written in binary code; tedious to program and hard to read or modify.
Role of an assembler
Converts assembly language programs into machine code.
Purpose of assembly language
Developed to make programming easier; requires an assembler to translate to machine code.
High-level language characteristics
English-like and easy to learn and program.
Why is Java used for Internet applications?
Java enables development and deployment on the Internet across servers, desktops, and handheld devices; it is described as the Internet programming language.
Java's scope according to notes
General-purpose programming language and Internet programming language.
Java application types listed
Standalone applications, applications running from a browser, applications for handheld devices, and web server applications.
List of Java characteristics
Simple; Object-Oriented; Distributed; Interpreted; Robust; Secure; Architecture-Neutral; Portable; Java’s performance; Multithreaded; Dynamic.
What does the sample program print?
Welcome to Java!
What is source code?
A program written in a high-level language that must be translated into machine code before execution, via a compiler or an interpreter.
What is bytecode and the JVM's role?
Java source is compiled into bytecode, which runs on any platform with a Java Virtual Machine that interprets the bytecode.
Java portability benefit
Write the program once and run it on any machine that has a JVM.
Anatomy of a Java program
Class name; main method; statements; statement terminator; reserved words; comments; blocks.
Class name convention
Class names start with an uppercase letter; example: Welcome.
Main method requirement
A class must contain a main method to run; the signature is public static void main(String[] args).
Statement
An action or sequence of actions in a program; e.g., printing a greeting.
Statement terminator
Semicolon ends a statement.
Keywords
Reserved words with special meaning to the compiler; cannot be used as identifiers.
Blocks
Braces { } form a block that groups components; includes class blocks and method blocks.
Special symbols list
Braces { }, parentheses ( ), brackets [ ], // for comments, quotation marks, and semicolon ;
Block Styles
Two brace styles: end-of-line style (brace on same line) and next-line style (brace on the next line).
Programming style and documentation
Involves appropriate comments, meaningful naming conventions, proper indentation/spacing, and block styles.
Appropriate comments content
Begin with a summary explaining the program’s purpose, features, data structures, and techniques; include name, class section, instructor, date, and description.
Naming conventions for classes
Choose meaningful names; class names capitalize the first letter of each word (e.g., ComputeExpression).
Indentation and spacing guideline
Indent by two spaces; use blank lines to separate segments of code.
Programming errors categories
Syntax errors (detected by the compiler); runtime errors (program aborts); logic errors (incorrect results).
Syntax error example
Illustrative example shows malformed main declaration and an unterminated string, highlighting a syntax error.
Runtime error example
Division by zero (1 / 0) illustrating a runtime error.
Logic error example
Incorrect Celsius-to-Fahrenheit calculation due to the wrong formula or integer division.
Quotation marks in strings
Strings are enclosed in double quotation marks.
Comment syntax
Single-line comments start with //.