Busy. Please wait.
or

show password
Forgot Password?

Don't have an account?  Sign up 
or

Username is available taken
show password

why


Make sure to remember your password. If you forget it there is no way for StudyStack to send you a reset link. You would need to create a new account.
We do not share your email address with others. It is only used to allow you to reset your password. For details read our Privacy Policy and Terms of Service.


Already a StudyStack user? Log In

Reset Password
Enter the associated with your account, and we'll email you a link to reset your password.
Don't know
Know
remaining cards
Save
0:01
To flip the current card, click it or press the Spacebar key.  To move the current card to one of the three colored boxes, click on the box.  You may also press the UP ARROW key to move the card to the "Know" box, the DOWN ARROW key to move the card to the "Don't know" box, or the RIGHT ARROW key to move the card to the Remaining box.  You may also click on the card displayed in any of the three boxes to bring that card back to the center.

Pass complete!

"Know" box contains:
Time elapsed:
Retries:
restart all cards
share
Embed Code - If you would like this activity on your web page, copy the script below and paste it into your web page.

  Normal Size     Small Size show me how

Chapter 1

Creating Java Programs

TermDefinition
Computer Program A set of instructions that you write to tell a computer what to do
Hardware Computer equipment, such as a monitor or keyboard
Software Programs
Application Software A program that performs a task for a user(such as calculating and producing paychecks, word processing, or playing a game)
System Software A program that manages the computer itself(such as Windows or Linux)
Logic The logic behind any computer program, whether it is an application or system program, determines the exact order of instructions needed to produce desired results
Machine Language or Machine Code Is the most basic set of instructions that a computer can execute. Each type of processor has its own set of machine language instructions. All computer programs ultimately are converted to machine language
Low-Level Programming Language One that corresponds closely to a computer processor's circuitry. Machine language is a low-level programming language
High-Level Programming Language Allows you to use a vocabulary of reasonable terms, such as read, write, or add, instead of the sequences of 1s and 0s that perform these tasks. Allow you to assign single-word, intuitive names to areas of computer memory. Java is a High-Level Language
Syntax Each high-level language has its own syntax, or rules of the language
Program statements Using a programming language, programmer write a series of program statements, similar to English sentences, to carry out the tasks they want the program to perform. Also known as commands because they are orders to the computer
Compiler or Interpreter After the program statements are written, high-level language programmers use a computer program called a compiler or interpreter to translate their language statements into machine language
Difference Between Compiler and Interpreter A compiler translates an entire program before carrying out the statement, or executing it, whereas an interpreter translates one program statement at at time, executing a statement as soon as it is translated
Syntax Error Compilers and interpreters issue one or more error messages each time they encounter and invalid program statement - that is, a statement containing a syntax error, or misuse of the language
Debugging Freeing the program of all errors
Locating and Repairing All Syntax Errors The first part of the process of debugging a program
Correcting Logical Errors The second part of debugging process and is much more difficult than correcting syntax errors
Semantic Errors Programmers call some logical errors semantic errors
Two Popular Approaches to Writing Computer Programs Procedural programming and object-oriented programming
Procedural Programming A style of programming in which operations are executed one after another in sequence. In procedural applications, you can create names for computer memory locations called variables that can hold values, like numbers and text, in electronic form
Variables Named computer memory locations that can hold values in electronic form. Called variables because they hold values that might vary
Procedures For convenience, the individual operations used in a computer program are often grouped into logical units called Procedures. Also called modules, methods, functions, and subroutines
Calling a Procedure When a program calls a procedure, the current logic is temporarily abandoned so that the procedure's commands can execute
Object-Oriented Programming An extension of procedural programming which involves creating classes, which are blueprints for objects; creating objects from those classes; and creating applications that use those objects
Two Major Types of Applications Object-Oriented Programming was Originally Used For 1. Computer Simulations.. 2. Graphical User Interfaces(GUIs)
Computer Simulations Attempt to mimic real-world activities so that their processes can be improved of so that users can better understand how the read-world processes operate
Graphical User Interfaces(GUIs) Allows users to interact with a program in a graphical environment
Understanding Object-Oriented Programming Requires Grasping Three Basic Concepts 1. Encapsulation as it applies to classes as objects.. 2. Inheritance.. 3. Polymorphism
Class A term that describes a group or collection of objects with common properties. A class definition exists before any objects are created from it
Class Definition Describes what attributes its objects will have and what those objects will be able to do
Attributes The characteristics that define an object; they are properties of an object
Object A specific, concrete instance of a class. When you create an object, you instantiate it
Object's State The values of the properties of an object are referred to as the object's state. Besides defining properties, classes define methods their objects can use
Method A self-contained block of program code that carries out some action, similar to a procedure in a procedural program. An Automobile, for example, might have methods for moving forward, moving, backward, being filled with gasoline, and being washed
1. Encapsulation Refers to two closely related object-oriented notions... 1. Encapsulation is the enclosure of data and methods within an object. Encapsulation allows you to treat all of an object's methods and data as a single entity.
2. Encapsulation Just as an actual dog contains all of its attributes and abilities, so would a program's Dog object.. 2. Encapsulation also refers to the concealment of an object's data and methods from outside sources. Concealing data is sometimes called information
3. Encapsulation hiding, and concealing how methods work is implementation hiding. Encapsulation lets you hide specific object attributes and methods from outside sources and provides the security that keeps data and methods safe from inadvertent changes
Inheritance An important feature of object-oriented program design is inheritance - the ability to create classes that share the attributes and methods of existing classes but with more specific features
Polymorphism A final important concept in object-oriented terminology. Means "many forms" and it describes the feature of languages that allows the same word or symbol to be interpreted correctly in different situations based on the context
Java Developed by Sun Microsystems as an object-oriented language for general-purpose business applications and for interactive, World Wide Web-based Internet Applications
Java is Architecturally Neutral Unlike other languages, you can use Java to write a program that runs on any operating system(such as Windows, Mac OS, or Linux) or device(such as PCs, phones, and tablet computers)
Java Virtual Machine(JVM) A hypothetical computer that Java runs on. Hypothetical in this case means it is not a physical entity created from hardware by is composed only of software
Source Code Programming statements written in a high-level programming language
Development Environment A set of tools that help you write programs by providing such features as displaying a language's keywords in color
Bytecode A binary program that the Java compiler converts the source code into
Java Interpreter A program that checks the bytecode and communicates with the operating system, executing the bytecode instructions line by line within the Java Virtual Machine
"Write once, run anywhere"(WORA) A slogan developed by Sun Microsystems to describe the ability of one Java program version to work correctly on multiple platforms
Java Program Types You can write two kinds of programs using Java... 1. Applets.. 2. Java Applications.. A. Console Applications.. B. Windowed Applications
Applets Programs that are embedded in a Web page
Java Applications Stand-alone programs. Java applications can be subdivided into Console Applications and Windowed Applications
Console Applications Support character output to a computer screen in a DOS window. These are the easiest applications to create
Windowed Applications Create a GUI with elements such as menus, toolbars, and dialog boxes.
Literal String of Character A series of characters that will appear in output exactly as entered
Arguments Pieces of information that are sent into a method, usually because the method requires the information to perform its task or carry out its purpose
Passing Arguments to the Method The act of sending arguments to a method
1. Java Statement Anatomy System.out.println("First Java application");... System is a class. out is an object defined in the System class. println() is a method. Method arguments are always followed by parentheses. Dots separate classes, objects, and methods.
2. Java Statement Anatomy "First Java application" is a literal string that is the argument to the println() method. Every Java statement ends with a semicolon. System defines attributes for System objects
The Java Methods println() and print() Both produce output. With println(), after the output is displayed, the insertion point(point where next output appears) moves to the following line. With print(), the insertion point does not advance to a new line; remains on line as output
Standard Output Device Within the statement System.out.println("First Java application");, out is an object that is a property of the system class that refers to the standard output device for a system, normally the monitor
1. Understanding the First Class Within the code..public class First{public static void main(String[] args){System.out.println("First Java application");}}...when you write public class First, you are defining a class named First
2. Understanding the First Class Everything that you use within a Java program must be part of a class. You can define a Java class using any name of identifier you need, as long as it meets the following requirements...
3. Understanding the First Class 1. A Java identifier must begin with letter of the English alphabet, a non-English letter(Greek), an underscore, or dollar sign. A class name cannot begin with a digit.. 2. A Java identifier can contain only letters, digits, underscores, or dollar signs
4. Understanding the First Class 3. A Java identifier cannot be a reserved keyword, such as public or class.. 4. A Java identifier cannot be one of the following values: true, false, or null. These are not keywords(they are primitive values), but they are reserved and cannot be used
Pascal Casing or Upper Camel Casing The style that joins words in which each begins with an uppercase letter. It is a Java standard, although not a requirement
1. Some Valid Class Names in Java 1. Class Name(Employee)...Description(Begins with an uppercase letter).. 2. Class Name(UnderGradStudent)...Description(Begins with an uppercase letter, contains no spaces, and emphasizes each new word with an initial uppercase letter)
2. Some Valid Class Names in Java 3. Class Name(InventoryItem)...Description(Begins with uppercase letter, contains no spaces, and emphasizes second word with an initial uppercase letter).. 4. Class Name(Budget2014)...Description(Begins with an uppercase letter and contains no spaces)
1. Legal but Unconventional and Nonrecommended Class Names in Java 1. Class Name(Undergradstudent)...Description(New words are not indicated with initial uppercase letters, making this identifier difficult to read).. 2. Class Name(Invetory_Item)...Description(Underscore is not commonly used to indicate new words)
2. Legal but Unconventional and Nonrecommended Class Names in Java 3. Class Name(BUDGET2014)...Description(Using all upercase letters for class identifiers is not conventional).. 4. Class Name(budget2014)...Description(Conventionally, class names do not begin with a lowercase letter)
1. Illegal Class Names in Java 1. Class Name(Inventory Item)...Description(Space character is illegal in identifier).. 2. Class Name(class)...Description(Class is reserved word).. 3. Class Name(2014Budget)...Description(Class names can't begin with a digit)..
2. Illegal Class Names in Java 4. Class Name(phone#)...Description( The number symbol(#) is illegal in an identifier)
Access Specifier The reserved word, public, is an access specifier. Defines the circumstances under which a class can be accessed and the other classes that have the right to use a class., Public access is the most liberal types of access
1. The Parts of a Typical Class Consult the code...public class First{public static void main(String[] args){System.out.println("First Java application");}}...
Class Body After the class header, you enclose the contents of a class within curly braces({}); any data items and methods between the curly braces make up the class body. Can be composed of any number of data items and methods
Whitespace Any combination of nonprinting characters. Optional in Java, used to organize your program code and make it easier to read
K & R Style The indent style in which opening braces are not on separate lines. Named for Kernighan and Ritchie, who wrote the first book on the C programming language
Allman Style The indent style in which curly braces are aligned and each occupies its own line. Named for Eric Allman, a programmer who popularized this style
1. The Parts of a Typical main() Method Consult the code...public class First{public static void main(String[] args){System.out.println("First Java application");}}...
2. The Parts of a Typical main() Method 1. In the method header public static void main(String[] args), the word public is an access specifier, just as it is when you use it to define the First class.. 2. In Java, the reserved keyword static means that a method is accessible and usable
3. The Parts of a Typical main() Method even though no objects of the class exist.. 3. The keyword void used in the main() method header indicated that the main() method does ont return any vlaue when it is called. Doesn't mean that main() doesn't product output, in this case it does.
4. The Parts of a Typical main() Method It only means that the main() method does not send any value back to any other method that might use it.. 4. The name of the method is main(). Not all classes have a main() method, many do not. All Java applications,
5. The Parts of a Typical main() Method however, must include a class containg a public method named main(), and most Java applications have additional classes and methods. When you execute a Java application, the JVM always executes the main() method first
Compiling a Java Class and Correcting Syntax Errors After you write and save application, two steps must occur before you can view the application's output.. 1. Compile the class you wrote(called the source code) into bytecode.. 2. Use the Java interpreter to translate bytecode into executable statements
Compile-Time Error An error in which the compiler detects a violation of language syntax rules and is unable to translate the source code to machine code
Parsing The process the compiler uses to divide your source code into meaningful portions
Logic Error An error that occurs when the syntax of the program is correct and the program compiles but produces incorrect results when you execute it. Often more difficult to find and resolve than syntax errors
Types of Errors Review Syntax errors are compile-time errors, A logic error is a type of run-time error - an error not detected until the program ask the computer to do something wrong, or even illegal, while executing,
Program Comments Nonexecuting statements that you add to a program for the purpose of documentation.
Commenting Out Statements When you comment out a statement, you turn it into a comment so that compiler does not translate it, and the JVM does not execute its command. Can help you pinpoint the location of errant statements in malfunctioning programs
Line Comments Start with two forward slashes(//) and continues to the end of the current line. A line comment can appear on a line by itself and at the end(and to the right) of a line following executable code. Do not require ending symmbol
Block Comments Start with a forward slash and an asterisk(/*) and end with an asterisk and a forward slash(*/). Can appear on a line by itself, in a line before executable code, or on a line after executable code. Also extend across as many lines as needed
Javadoc Comment Special case of block comments called documentation comments 'cause are used to automatically generate nicely formatted program documentation with program named javadoc. Begins with, /**, and ends with, */
Dialog Box A GUI object resembling a window in which you can place messages you want to display. Java contains a class named JOptionPane that allows you to produce dialog boxes
Java API The Java Application programming interface, more commonly referred to as the Java API. Also called the Java class library. Contains information about how to use every prewritten Java class, including lists of all the methods you can use with the classes
SDK(Software Development Kit) The JDK is a software development kit which includes tools used by programmers