Chapter 1 Revel Java

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

string

a sequence of characters, must be enclosed in double quotation marks

line comment

comments preceded by two slashes //

java language specification

is a technical definition of the java programming language's syntax and semantics

Write a complete main method that prints "Hello, world" to the screen.

public static void main(String args[]) { System.out.println("Hello, world"); System.exit(0); }

library

same as an API

high level languages

same as high level programming language

memory

stores data and program instructions for the CPU to execute

Cloud storage

stores documents that can be shared online, can be accessed from any device

software

the invisible instructions that control the hardware and make it work

Special characters and their meanings:

{} : opening and closing braces, denote a block to enclose statements () : opening and closing parentheses, used with methods []: opening and closing brackets, denota an array // :double slashes, precede a comment line "" : opening and closing quotation marks, enclose a string AKA a sequence of characters ; : semicolon, mark the end of a statement

bytecode verifier

A program in the JVM that checks the validity of the bytecode and ensures that the bytecode does not violate Java's security restrictions.

Java Runtime Environment (JRE)

A program that allows the computer to run java applications.

integrated development environment (IDE)

An application that includes an editor (a sort of programmer's word processor), debugger, and compiler, among other tools.

bytecode

Compiled Java source code.

Random Access Memory (RAM)

Computer location where instructions and data are stored on a temporary basis. This memory can be accessed in any order. The more RAM, the faster the computer can operate.

println

DOES move the code placed after it into the next line under it

block comment

Enclosed between /* and */ on one or several lines in the source code. when it sees this, the compiler scans for the next */. the example from this chapter displays Welcome to Java!

javac command

The command to invoke the compiler to compile a Java source code program from the command line.

class loader

When executing a Java program, the JVM first loads the bytecode of the class to memory using a program called the class loader. If your program uses other classes, the class loader dynamically loads them just before they are needed.

bit

a binary digit 0 and 1

network interface card (NIC)

a device to connect a computer to a local area network (LAN), which is commonly used in business, universities, and gov organizations

assembler

a program that translates assembly-language program into machine code

gigabyte (GB)

about 1 billion bytes

Java Development Kit (JDK)

defines the java API and contains a set of command line utilities, such as javac (compiler) and java (interpreter).

operating system (OS)

program that manages and controls a comuter's activities like windows, linux, or solaris

The formula for computing the discriminant of a quadratic equation ax^2 + bx + c = 0 is b^2 - 4ac. Write a program that computes the discriminant for the equation 3x^2 + 4x + 5 = 0. Class Name: Exercise01_01Extra

public class Exercise01_01Extra { public static void main(String[] args) { System.out.println(4 * 4 - 4 * 3 * 5); } }

Write a program that displays the result of 9.5 * 4.5 - 2.5 * 345.5 - 3.5 Class Name: Exercise01_05

public class Exercise01_05 { public static void main(String[] args) { System.out.println((9.5 * 4.5 - 2.5 * 3) / (45.5 - 3.5)); } }

statement

unit of ode that represents an action or a sequence of actions

4 main types of storage devices

- magnetic disk drives - optical disc drives (CD and DVD) - universal serial bus (USB) flash drives - cloud storage

java virtual machine (JVM)

A machine that runs Java bytecode. It is called virtual because it is usually implemented in software rather than in hardware.

block

A sequence of statements enclosed in braces ({}).

hard disks

Permanently store data and programs. Usually encased inside the computer, but removable disks are also available

Write a statement that prints "Hello, world" to the screen

System.out.println("Hello, world");

Suppose your name was Alan Turing. Write a statement that would print your last name, followed by a comma, followed by a space and your first name.

System.out.println("Turing, Alan");

bus

a system that connects all the components of the computers together

byte

a unit of storage. each byte consists of 8 bits. the size of the hard disk and memory is measured in bytes. a megabyte is roughly a million bytes

keywords or reserved word

a word defined as part of java language, which has a specific meaning to the compiler and cannot be used for other purposes in the program EXAMPLES: when the compiler sees the word class, it understand that the word after class is the name for the class

megabyte (MB)

about 1 million bytes

terabyte (TB)

about 1 trillion bytes

kilobyte (KB)

about 1,000 bytes

multithreading

allows a single program to execute multiple tasks at the same time

multiprogramming

allows multiple programs like microsoft word, email, and a web browser to run simultaneously by sharing the same CPU

program

also know as software - this is what is created when you program!

dot pitch

amount of space between pixels measures in millimeters

java

developed by james gosling at sun microsystems. originally called Oak. designed for use in embedded chips in consumer electronic appliances, then redesigned for develiping web applications it is simple, object oriented, distributed, interpreted, robuts, secure, architecture nertral, portable, high performance, multithreaded and dynamic

drives

devices for operating a medium, like disks and CDs

core

part of the processor that performs the reading and executing of instructions. to increase CPU processing power, chip manufacturers now produce CPUs that have multiple cores

print

putting System.out.print does NOT move the code put after it to the next line down

low-level language

refers to assembly language

documentation

the body of explanatory remarks and comments pertaining to a program

if you execute a class file that does not have a main method or you mistype the main method (like typing Main instead of main) then a.....

NoSuchMethodError will occur

logic errors

Occur when the program compiles and executes, but the output is not what you wanted/expected.

hardware

the physical aspect of the computer that can be seen Consists of: Central Processing Unit (CPU), memory (main memory), storage devices (like disks and CDs), input devices (like a mouse and keyboard), output devices (like moniters and printers), and communication devices (such as modems and network interface cards (NIC))

programming

the process for writing a program

DVDs and the two types of DVDs

stands for digital versatile disc or digital video disk. holds MORE information than a CD, about 4.7 GB TWO TYPES: - DVD-R: R stands for Recordable

javadoc comments

starts with a forward slash and two asterisks (/**) and end with an asterisk forward slash (*/) Are used to for commenting on an entire class or method and must precede the class or method header in order to be extracted into a javadoc HTML file

how to format your source file name

the file should be named the same thing as the public class name so if my public class name is Welcome, then the file name will be named Welcome.java

storage devices

the permanent storage for data and programs. memory is volatile, because information is lost when the power is off. program and data are stored on secondary storage and moved to memory when the computer actually uses them.

statement terminator

the semicolon is the statement terminator symbol in java

review of this chapter

A computer is an electronic device that stores and processes data. A computer includes both hardware and software. Hardware is the physical aspect of the computer that can be touched. Computer programs, known as software, are the invisible instructions that control the hardware and make it perform tasks. Computer programming is the writing of instructions (i.e., code) for computers to perform. The central processing unit (CPU) is a computer's brain. It retrieves instructions from memory and executes them. Computers use zeros and ones because digital devices have two stable states, referred to by convention as zero and one. A bit is a binary digit 0 or 1. A byte is a sequence of 8 bits. A kilobyte is about 1,000 bytes, a megabyte about 1 million bytes, a gigabyte about 1 billion bytes, and a terabyte about 1,000 gigabytes. Memory stores data and program instructions for the CPU to execute. A memory unit is an ordered sequence of bytes. Memory is volatile, because information is lost when the power is turned off. Programs and data are permanently stored on storage devices and are moved to memory when the computer actually uses them. The machine language is a set of primitive instructions built into every computer. Assembly language is a low-level programming language in which a mnemonic is used to represent each machine-language instruction. High-level languages are English-like and easy to learn and program. A program written in a high-level language is called a source program. A compiler is a software program that translates the source program into a machine-language program. The operating system (OS) is a program that manages and controls a computer's activities. Java is platform independent, meaning you can write a program once and run it on any computer. The Java source file name must match the public class name in the program. Java source-code files must end with the .java extension. Every class is compiled into a separate bytecode file that has the same name as the class and ends with the .class extension. To compile a Java source-code file from the command line, use the javac command. To run a Java class from the command line, use the java command. Every Java program is a set of class definitions. The keyword class introduces a class definition. The contents of the class are included in a block. A block begins with an opening brace ({) and ends with a closing brace (}). Methods are contained in a class. To run a Java program, the program must have a main method. The main method is the entry point where the program starts when it is executed. Every statement in Java ends with a semicolon (;), known as the statement terminator. Keywords have a specific meaning to the compiler and cannot be used for other purposes in the program. In Java, comments are preceded by two slashes (//) on a line, called a line comment, or enclosed between /* and */ on one or several lines, called a block comment or paragraph comment. Comments are ignored by the compiler. Java source programs are case sensitive. Programming errors can be categorized into three types: syntax errors, runtime errors, and logic errors. Errors reported by a compiler are called syntax errors or compile errors. Runtime errors are errors that cause a program to terminate abnormally. Logic errors occur when a program does not perform the way it was intended to.

multiprocessing

like multithreading, is for running multiple programs concurrently using multiple processors

assembly language

low level programming language in which a mnemonic is used to represent each of the machine language instructions

common mistakes people make

missihng braces { missing semicolons ; missing quotation marks " misspelling names, like writing Main instead of main

Java standard edition (Java SE)

one of the editions of java. used to develop client-side applications which can run on a desktop

pixel

short for picture elements. the tiny dots that form an image on screen

interpreter

software for interpreting and running java bytecode

CDs

stands for compact disk. THREE TYPES: - CD-ROM: a prepressed disc. popular for distriburing software, music, and video, which are now distributed on the internet without the use of a CD - CD-R: aka CD-Recordable, is a write once medium which can be used to record data once and read any number of times. - CD-RW: aka CD-ReWritable, can be used like a hard disk (you can write data onto the disc and then overwrite that data with new data. a single CD can hold up to 700 MB

USB flash drives

stores and transports data. allow the user to attach many kinds of peripheral devices to the computer. can connect to printers, digital cameras, mouse, external hard drives, and other devices. is essentially a PORTABLE HARD DRIVE. holds up about 256 GB

method

the starting method for executing a program

to compile and run a single file source code program...

use java ClassName.java

Java Micro edition (java ME)

used to develop applications for mobile devices, such as cell phones

Java enterprise edition (Java EE)

used to develop sever side applications, like java servlets, javaserver pages (JSP), and javaserver faces (JSF)

indentation

used to illustrate the structural relationships between a program's components or statements.

digital subscriber line (DSL)

uses a phone line and can transfer data in a speed 20 times faster than a regular modem

dial up modem

uses phone line to dial a phone number to connect to the internet and can transfer data at a speed up to 56,000 bps (bits per second

cable modem

uses the cable line maintained by the cable company and is generally faster than DSL

screen resolution

specifies the number of pixels per square inch. the higher the resolution, the sharper and clearer the image is

application program interface (API)

a set of classes and interfaces that can be used to develop java programs

CPU (Central Processing Unit)

a small silicon semiconductor chip with millions of transistors that executes instructions. This is the computer's brain! It retrieves instructions from the memory and executes them. The unit of measurement of clock speed is the hertz (Hz), where 1 hertz equals 1 pulse per second. Clock speed of a computer is usually stated in megahertz (MHz (1 MHz is 1 million Hz) TWO COMPONENTS: control unit and an arithmetic/logic unit (which performs numeric operations like addition, subtraction, multiplication and division and logical operations aka comparisons)

programming style

deals with what programs look like. can compile and run properly even if written on only one line, but writing it all in one line sucks to look at

input and output devices

devices that are used to input to a computer (keyboard, mouse) or output (monitor)

comment

document what a program is and how it is constructed. not programming statements and are ignored by the compiler. to write one, enter two slashes // in a line

syntax errors or compile errors

errors reported by the compiler, result of errors in code construction like mistyping a keyword or omitting necessary punctuation

runtime errors

errors that cause a program to terminate abnormally, occur while a program is running if the environment detects an operation that is impossible to carry out. normally caused by input mistakes

source program/source code

a program written in a high level language

block

group of statements surrounded by braces. there are two types- next line (aligns braces vertically and makes programs easy to read) and end of line (saves space and may help avoid subtle programming errors

motherboard

is a circuit case that connects all of the parts of a computer together

machine language

is a set of primitive instructions built into every computer. the instructions are in the form of binary code, so you have to enter binary codes for various instructions

if you execute a class file that does not exist, a...

NoClassDefFoundError will occur


Kaugnay na mga set ng pag-aaral

Chapter 10: Seeking and Developing Target Marketing Differentiation Strategies

View Set

High School Academy Honors Biology - Unit 8 - DNA - Part 1

View Set

Unit 2: : Population and Migration Patterns and Processes

View Set

ESC5 Lesson 6 Text Two - 狄晓晴

View Set

Page 73 Exercise 25 Future Expressions

View Set

Module 11 (Intracranial Regulation and Cognition)

View Set

Korsgaard: Aristotle's Function Argument

View Set