INFS 3310 Final
Interface
An interface in the Java programming language is an abstract type that is used to specify a behavior that classes must implement. They are similar to protocols. Interfaces are declared using the interface keyword, and may only contain method signature and constant declarations (variable declaratire declared to be both static and final). All methods of an Interface do not contain implementation (method bodies) as of all versions below Java 8. Starting with Java 8, default and static methods may have implementation in the interface definition.[1]
Central Processing Unit
At the heart of a computer is its central processing unit, or CPU. The CPU's job is to fetch instructions, follow the instructions, and produce some resulting data. Internally, the central processing unit consists of two parts: the control unit and the arithmetic and logic unit (ALU). The control unit coordinates all of the computer's operations. It is responsible for determining where to get the next instruction and regulating the other major components of the computer with control signals. The arithmetic and logic unit, as its name suggests, is designed to perform mathematical operations.
Random access memory
Commonly known as random access memory, or RAM, the computer's main memory is a device that holds information. Specifically, RAM holds the sequences of instructions in the programs that are running and the data those programs are using.
Compile time
Compile time errors: When we feed a bunch of text to the compiler to convert it to machine code.
Source Code
Filename is the name of a file that contains the Java source code. As mentioned earlier, this file has the .java extension. For example, if you want to compile the Payroll.java file, you would execute the following command: javac Payroll.java
Java
Java is an object-oriented language invented at Sun Microsystems, and is now owned by Oracle. It may be used to develop stand-alone applications that operate on a single computer, applications that run over the Internet from a Web server, and applets that run in a Web browser.
Subclass
You can think of the subclass as an extended version of the superclass. The subclass inherits fields and methods from the superclass without any of them having to be rewritten. Furthermore, new fields and methods may be added to the subclaVehicle
Inheritance
a class based on another class. Means that one class is a specialized case of the other.
Constructor
a method that automatically calls when an object is created (pg 155). Used to reduce writing same code over and over again
Java Virtual Machine (JVM)
a program that simulates a computer whose machine language is Java bytecode. It executes the java byte code instructions. The JVM has two primary functions: to allow Java programs to run on any device or operating system, and to manage and optimize program memory.
public (keyword)
an access specifier, and controls where class may be accessed from; access to class is unrestricted
Pseudocode
cross between human language and a programming language, useful when designing an algorithm. Source code without syntaxHelps prevent logicala errors, in which the program produces erroneous results.
Task decomposition
decomposing an algorithm means breaking it down to several short methods, each performing a specific task. Helps to debug and is easier to read.
Encapsulation
distinction between private and public. Class controls access. To see the data use get method (Assessor), to change the attributes use the set method (mutator). Once you write it, embed it on the class, there is only one place to go and change the data.
Programming language keywords
float -A data type that holds a 32-bit floating-point number For dollar amounts or precise measurements, and saves more memory compared to double. (refer to pg 51 for example) case - Used in switch statements to mark blocks of text extends -Indicates that a class is derived from another class or interface If -Tests a true/false expression and branches accordingly import -References other classes int - A data type that can hold a 32-bit signed integer (natural number) double - A data type that can hold 64-bit floating-point numbers (decimal points) package - Declares a Java package private -An access specifier indicating that a method or variable may be accessed only in the class it's declared in public - An access specifier used for classes, interfaces, methods, and variables indicating that an item is accessible throughout the application (or where the class that defines it is accessible) static -Indicates that a variable or method is a class method (rather than being limited to one particular object) return -Sends control and possibly a return value back from a called method new - Creates new objects char - A data type that can hold unsigned 16-bit Unicode characters Enclosed in single quotation marks, example: 'A' switch -A statement that executes code based on a test value void -Specifies that a method does not have a return value
literal
hardcoded name or value
Class header
marks the beginning of a class definition. Serve as a container for an application
.class file extension
bytecode is stored in a file with the .class extension
I/O
Although this program does not have any code that directly performs file I/O, we still have to have this import statement because of the throws IOException clause in the main method header. The main method has to have the throws IOException clause because it calls the saveReport method in the Amortization class.
Identifiers
An identifier is a programmer-defined name that represents some element of a program. Variable names and class names are examples of identifiers. You may choose your own variable names and class names in Java, as long as you do not use any of the Java key words. The key words make up the core of the language and each has a specific purpose.
Attributes
The data contained in an object is known as the object's attributes.
Arithmetic Operations
+ Addition Binary total = cost + tax; − Subtraction Binary cost = total − tax; * Multiplication Binary tax = cost * rate; / Division Binary salePrice = original / 2; % Modulus Binary remainder = value % 3;
Comments
// or / /
double
A data type that can hold 64-bit floating-point numbers (decimal points)
Boolean operators
A data type that can hold True and False values only. The content of a boolean variable may not be assigned to a variable other than boolean (pg 53)
int
A data type that can hold a 32-bit signed integer (natural number)
Methods
A default method is an interface method that has a body
Programming
A program is a set of instructions a computer follows in order to perform a task. A programming language is a special language used to write computer programs
Java Runtime Environment (JRE)
A subset of the Java Development Kit (JDK) for end-users and developers who want to redistribute the runtime environment alone. The Java runtime environment consists of the Java virtual machine1, the Java core classes, and supporting files.
Runtime
At runtime, the user may select an item in the list, which causes the item to appear highlighted. In the figure, the first name is selected.
Data types
DataType is the name of the data type and VariableName is the name of the variable. Here are some examples of variable declarations: byte inches; int speed; short month; float salesCommission; double distance;
Integrated Development Environment
In addition to the command prompt programs, there are also several Java integrated development environments (IDEs). These environments consist of a text editor, compiler, debugger, and other utilities integrated into a package with a single set of menus. A program is compiled and executed with a single click of a button, or by selecting a single item from a menu.
/n
Insert a new line in the text at this point.
Machine Language
Machine language code is executed directly by the CPU. Because machine language programs are streams of binary numbers, and highlevel language programs are made up of words.
Operators
Operators are symbols or words that perform operations on one or more operands. An operand is usually an item of data, such as a number.
Secondary storage
Secondary storage holds data for long periods of time—even when there is no power to the computer. The most common type of secondary storage device is the disk drive. A traditional disk drive stores data by magnetically encoding it onto a spinning circular disk. Solid state drives, which store data in solid-state memory, are increasingly becoming popular. A solid-state drive has no moving parts, and operates faster than a traditional disk drive.
Program statements
Single line comments: You simply place two forward slashes (//) where you want the comment to begin. The compiler ignores everything from that point to the end of the line. Multi-line comments: start with /* (a forward slash followed by an asterisk) and end with */ (an asterisk followed by a forward slash). Everything between these markers is ignored. Documentation comment: starts with /** and ends with */ is considered a documentation comment. Normally you write a documentation comment just before a class header, giving a brief description of the class.
Virtual Machine
The JVM is a program that reads Java byte code instructions and executes them as they are read. For this reason, the JVM is often called an interpreter, and Java is often referred to as an interpreted language.
Bytecode
The Java compiler, however, translates a Java source file into a file that contains byte code instructions. Byte code instructions are not machine language, and therefore cannot be directly executed by the CPU. Instead, they are executed by the Java Virtual Machine (JVM). The JVM is a program that reads Java byte code instructions and executes them as they are read. For this reason, the JVM is often called an interpreter, and Java is often referred to as an interpreted language.
Strings
The String class allows you to create objects for holding strings. It also has various methods that allow you to work with strings. EX: "Hello World" "Joe Mahoney"
Arithmetic Unit
The arithmetic and logic unit, as its name suggests, is designed to perform mathematical operations.
Compiler
The compiler will create another file named Simple.class, which contains the translated Java byte code. This file can be executed with the following command: java Simple
Method header
The header is where you tell Java what value type, if any, the method will return (an int value, a double value, a string value, etc). As well as the return type, you need a name for your method, which also goes in the header. You can pass values over to your methods, and these go between a pair of round brackets.
Variables
The most fundamental way that a Java program stores an item of data in memory is with a variable. A variable is a named storage location in the computer's memory. The data stored in a variable may change while the program is running (hence the name "variable"). Variables are symbolic names made up by the programmer that represent locations in the computer's RAM. When data is stored in a variable, it is actually stored in RAM. Assume that a program has a variable named length.
Logic Unit
The part of the CPU that performs arithmetic computations and logical operations
Compiled Code
The program shown in Code Listing 2-1 is named Simple.java. Using the Java compiler, this program may be compiled with the following command: javac Simple.java
Strings (class and objects)
The string class allows you to create objects for holding strings. Example— String name; Remember String is a class A class can be used to specify the attributes and methods that particular type of object may have (think of class as a blueprint from which objects may be created from). Class is a description of the object. Each object that is created from a class is called an instance of the class
Superclass
The superclass is the general class and the subclass is the specialized class. You can think of the subclass as an extended version of the superclass. The subclass inherits fields and methods from the superclass without any of them having to be rewritten. Furthermore, new fields and methods may be added to the subclaVehicle (pg23)
Arguments
The value that is inside the parentheses.
Programming syntax
These are rules that must be followed when writing a program. Syntax dictates how key words and operators may be used, and where punctuation symbols must appear.
Static (keyword)
if a field is declared static, then exactly a single copy of that field is created and shared among all instances of that class. It doesn't matter how many times we initialize a class; there will always be only one copy of static field belonging to it. The value of this static field will be shared across all object of either same of any different class.
Javac
is the standard Java compiler and part of the Java Development Kit. It creates bytecode for the Java Virtual Machine from valid Java code. Run thru command prompt.
.java file extension
java extension — is java source files end with the .java (source code———> .java... after compiling into bytecode————>.class)
Void (keywords)
method does not return anything