Chapter 1: Creating Java Programs Flashcards
Computer program
A set of written instructions that tells the computer what
to do
Machine language
– The most basic circuitry-level language
– A low-level programming language
High-level programming language
Allows you to use a vocabulary of reasonable terms
Syntax
A specific set of rules for the language
Program statements
– Similar to English sentences
– Commands to carry out program tasks
Compiler
Translates language statements into machine code
Syntax error
Misuse of language rules
Object-oriented programs
– Create classes
• Blueprints for an object
– Create objects from classes
– Create applications
Object-oriented programming was used most frequently for
three major types of applications
– Development of Scientific Applications
– Web, Mobile, Game, and Enterprise Applications
– Graphical user interfaces (GUIs)
Class
Describes objects with common properties
Objects
Specific, concrete instances of a class
Method
A self-contained block of program code that carries out an
action
Encapsulation
Conceals internal values and methods from outside
sources
Java
– Developed by Sun Microsystems
– An object-oriented language
– General-purpose
– Advantages
• Security features
• Architecturally neutral
– Can be run on a wide variety of computers
– Does not execute instructions on the computer directly
– Runs on a hypothetical computer known as a Java Virtual
Machine (JVM)
Source code
Programming statements written in high-level
programming language
Development environment
A set of tools used to write programs
Bytecode
– Statements saved in a file
– A binary program into which the Java compiler converts
source code
Java interpreter
– Checks bytecode and communicates with the operating
system
– Executes bytecode instructions line by line within the Java
Virtual Machine`
Applets
Programs embedded in a Web page
Java applications
Called Java stand-alone programs
– Console applications
We will write these types of applications this semester.
• Support character output
– Windowed applications
• Menus
• Toolbars
• Dialog boxes
Literal string
Written between double quotation marks
Arguments
Pieces of information passed to a method
System class
Refers to the standard output device for a system
static
Means the method is accessible and usable even though no objects of the class exist
void
– Use in the main() method header
– Does not indicate the main() method is empty
– Indicates the main() method does not return a value
when called
– Does not mean that main() doesn’t produce output
WHAT TO TYPE: Compiling a Java class
javac First.java
Compile-time error
– The compiler detects a violation of language rules – Refuses to translate the class to machine code
Parsing
Compiler divides source code into meaningful portions
Run-time error
– Not detected until execution
– Often difficult to find and resolve
Line comments
- Start with two forward slashes (//)
* Continue to the end of the current line
Block comments
- Start with a forward slash and an asterisk (/*)
* End with an asterisk and a forward slash (*/)
package
A group of classes