Java Chapter 1

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Denote an array.

[]

By convention, class names start with

an uppercase letter

The Java Application Programming Interface (API) species how your programs may use the Java _, a large base of Java classes to make programming easier

class libraries

Java SE Runtime Environment 7 (JRE 7) contains

class libraries (JVM & Java: needed to run Java applications)

Packages are hierarchical, and you can have packages within packages. For example, java.lang.Math indicates that Math is a _ in the _ lang and that lang is a _within the _ java.

class, package (3)

The API is a large collection of ready-made software components that provide many useful capabilities. It is grouped into libraries of related __; these libraries are known as _.

classes & interfaces, packages

Errors that are detected by the compiler are called syntax errors or _

compile errors

The _ reports syntax errors.

compiler

The Java Application Programming Interface (API) usage 2:

compiler: checks (code using the API correctly)

All letters in _ should be capitalized

constants

(sixth line) Write a program Five that displays Welcome to Java five times.

i++;

For variables and methods, always use _

lowercase

Methods are contained in a class. To run a Java program, the program must have a _: the entry point where the program starts when it is executed.

main method

The program is executed from the main method. A class may contain _.

more than one method

Application Programming Interface (API): The API provides the core functionality of the Java programming language. It offers a wide array of useful classes ready for use in your own applications. It spans everything from basic objects, to _, to XML generation and database access, and more.

networking and security

STYLE TYPE: public class Test { public static void main(String[] args) { System.out.println("Block Styles"); } }

next-line style

A block is a group of statements surrounded by braces. There are two popular styles, _ & _, as shown below

next-line, end-of-line

Prints a String and then terminate the line. This method behaves as though it invokes print(String) and then println().

println()

Enclose a string (i.e., sequence of characters).

""

Used with methods.

()

aMethod(a1, a2), aMethod ( a1, a2 ). Which (1 or 2) is good style?

1

The _ Documentation contains the documentation for the software development tools, the official documentation of the Java SE API, as well as providing links to many other documents. You should begin to investigate this in this subject.

JDK 7

The __ provides standard mechanisms such as the Java Web Start software and Java Plug-In software for deploying your applications to end users.

JDK software

The _ (Gosling et al., 2005) is the technical definition of the Java programming language. You won't need it for this subject. However, it is useful to know that Java is well-specifed. Unlike some other languages you do not have to cope with a multiplicity of variants.

JLS

The current version is Java SE 7. It consists of two software products

JRE 7, JDK 7

Java bytecode can be executed on any computer with a _

JVM

Welcome.class (Java bytecode executable file) exectuted by

JVM

The Java platform has two components:

JVM, API (The Java Virtual Machine; The Java Application Programming Interface (API))

The Java Application Programming Interface (API) usage 3:

JVM: runtime (to access any Java class libraries program needs)

(third line) Write a program Five that displays Welcome to Java five times.

int i = 0;

If you execute a class file that does not exist, a _ will occur

NoClassDefFoundError

Java was originally called _ until _

Oak, 1995

(Third line) Write a program called Welcome that displays Welcome to Java

System.out.println("Welcome");

What is the statement to display a string on the console?

System.out.println();

What symbol is used to terminate a statement?

;

Every statement in Java ends with a, known as the _

;, statement terminator

determines what a program looks like

Programming style

(first line) Write a program Five that displays Welcome to Java five times.

public class Five {

(First line) Write a program called Welcome that displays Welcome to Java

public class Welcome {

Java designers recommend that you use your Internet domain name in _ as a package prefix.

reverse order (e.g. mypackage.io on much with domain name liang.cs.armstrong.edu. = edu.armstrong.cs.liang.mypackage.io)

Another example of _ is division by zero.

runtime errors

The output of the Java compiler; contains the byte code for the class.

.class file

The source code of a Java program. It may contain one or more Java classes and interfaces; can be created using a text editor or a Java IDE such as NetBeans, Eclipse, and JBuilder

.java file

javadoc comments begin with _ and end with _.

/**, */

Java was designed in _

1991

Mark the end of a statement.

;

(Full name) A set of classes and interfaces that can be used to develop Java programs.

Application Program Interface

write compute area as a class name

ComputeArea

is the body of explanatory remarks and comments pertaining to a program.

Documentation

IDE

Integrated Development Environment (Software that helps programmers write code efficiently)

JDK 7

Java SE Development Kit 7

JRE 7

Java SE Runtime Environment 7

Capable of compiling each bytecode once, and then reinvoking the compiled code repeatedly when the bytecode is executed

Just-in-Time compiler

Sun Microsystems was purchased by _ in _

Oracle, 2010

The Java Platform, Standard Edition (Java SE) is the name for the particular edition of the platform of Java software that you will use in this subject. The current version is Java _.

SE 7

A program that translates assembly-language programs into machine code.

assembler

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

assembly language

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

block

Java expects one-to-one mapping of the package name and the file system directory structure. A package is actually a directory that contains the _.

bytecode of the classes

The Java Application Programming Interface (API) usage 1:

documentation (of the API; how to use classes)

STYLE TYPE: public class Test { public static void main(String[] args) { System.out.println("Block Styles"); } }

end-of-line style

An integrated development environment (IDE) provides a _ that integrates the programmer's tasks of editing, compiling and running a program

graphical user interface

With Java, the source code is compiled to an _, called bytecode. This is then run by an interpreter, called the JVM (Java Virtual Machine), which also performs the _. Java bytecode can be passed to different platforms and run immediately, provided only that they have their appropriate JVMs to run it.

intermediate form, linkage step

Software for interpreting and running Java bytecode.

interpreter

It is sometimes stated that Java's use of an _ makes it slow. This was only a problem with early JVMs. Current JVMs build up machine code translations of _ used portions of bytecode as a program is running. . This eliminates much repeated interpretation

interpreter, frequently

Use _ comments at the beginning of the program to state your name, class, and give a brief description for the program.

javadoc

Use _ comments to describe an entire _.

javadoc, method

classic approach, high-level source code compiled to machine code, & linked with _ to form an executable program. The machine code is platform-dependent; it is not portable between different platforms. The source code is portable, but it always needs the additional, often time-consuming, steps of compilation and linking to produce an executable program for the new platform.

library code

Use _ comments to describe steps inside a method.

line

The "standard" output stream. This stream is already open and ready to accept output data. Typically this stream corresponds to display output or another output destination specified by the host environment or user.

out

The Java SE Runtime Environment 7 (JRE 7) contains the JVM and the Java class libraries needed to run Java applications. This is the public JRE that a developer can redistribute with a Java application. Alternatively, a developer can distribute a Java application, specifying that it needs the _.

public JRE

setup a class called welcome

public class Welcome

The Java SE Development Kit 7 (JDK 7) contains all the JRE 7 components plus _, which include the compiler. These JRE components are not for redistribution

software development tools (... they include a private JRE for applications being developed, whose requirements might not be satisfied by the public JRE used to run other Java applications on the computer that contains the development environment.)

The Java platform differs from most other platforms in that it's a _ platform that runs on top of other _ platforms.

software only, hardware based

A file that stores the source code.

source file

specifies a single class in the import statement. For example, import javax.swing.JOptionPane imports JOptionPane from package javax.swing.

specific import

The __ contains several useful class fields and methods. It cannot be instantiated.

system class

Indent each subcomponent or statement at least _ more than the construct within which it is nested.

two spaces

Choosing a _ is important because your package might be used on the Internet by other programs.

unique name

(fourth line) Write a program Five that displays Welcome to Java five times.

while (i < 5){

imports all the classes in a package. For example, import javax.swing.* imports all classes from package javax.swing. import javax.swing.*;

wildcard import

"The source file must end with the extension _ and must have the same exact name as the _. For example, the file for the source code in Listing 1.1 should be named _, since the public class name is Welcome."

.java, public class name, Welcome.java

Precede a comment line.

//

What programming language does Android use?

Java

Welcome.java (Java Source code file): compiled by:

Java compiler

Write a statement to display "Good Morning".

System.out.println("Good Morning");

(fifth line) Write a program Five that displays Welcome to Java five times.

System.out.println("Welcome to Java");

Applets

Web browser programs

Java Compiler generates. Give Welcome. file name. Give answer.

Welcome.class, bytecode

A pair of curly braces in a program forms ___. Each begins with an opening brace ({) and ends with a closing brace (}).

a block (that groups the program's components)

Every Java program must have

at least one class

"An _ occurs when the program is waiting for the user to enter a value, but the user enters a value that the program cannot handle. For instance, if the program expects to read in a number, but instead the user enters a string, this causes data-type errors to occur in the program."

input error

The program is executed from the _

main method

"Before you can create Java programs, you need to first create a _: which is like a folder to hold Java programs and all supporting files."

project

"The Java source file name must match the _. Java source code files must end with the .java extension."

public class

(Second line) Write a program called Welcome that displays Welcome to Java

public static void main(String[] args) {

(second line) Write a program Five that displays Welcome to Java five times.

public static void main(String[] args) {

"which are the reserved words in this program: which are the reserved words in this program: 1 public class Welcome { 2 public static void main(String[] args) { 3 // Display message Welcome to Java! on the console 4 System.out.println("Welcome to Java!"); 5 } 6 }

public, class, static, void

_ _ _ have a specific meaning to the compiler and cannot be used for other purposes in the program.

reserved or keywords

Programming errors can be categorized into three types:

syntax, runtime, logic

class Welcome { public static void main(String[] args) { // Display message Welcome to Java! on the console ...(say welcome)

system.out.println("Welcome");

Denote a block to enclose statements.

{}

technical definition of the Java programming language's syntax and semantics.

Java language specification

_ occur when a program does not perform the way it was intended to.

Logic errors

If you execute a class file that does not have a main method or you mistype the main method (e.g., by typing Main instead of main), a _ will occur

NoSuchMethodError

_ and _ are two free popular integrated development environments for developing Java programs. _

NetBeans, Eclipse

Java was developed at _

Sun Microsystems

After a class is loaded, the JVM uses a program called the _ to check the validity of the bytecode to ensure that the bytecode does not violate Java's security restrictions. Java enforces strict security to make sure that Java class files are not tampered with and do not harm your computer.

bytecode verifier

"A Java compiler translates a Java source file into a _ file. The following command compiles Welcome.java: _"

bytecode, javac Welcome.java

A method is a construct that contains _

statements

To run a Java class from the command line, use the __.

java command

developed by the programmer

source code

"A _ should be added on both sides of a binary operator, as shown in the following statement: System.out.println(3 + 4 * 4);"

space (single)

JVM, is an interpreter which translates the individual instructions in the bytecode into the target _ one at a time rather than the whole program as a single unit. Each step is executed immediately after it is translated.

machine language (machine language code)

For variables and _, always use lowercase. If the name consists of several words, concatenate them into one, making the first word lowercase and _ the first letter of each subsequent word in the name

methods, capitalizing

Java source programs are case _. It would be wrong, for example, to replace main in the program with Main.

sensitive

_ are errors that cause a program to terminate abnormally.

Runtime errors

"The bytecode is similar to machine instructions but is _ and can run on any platform that has a _

architecture neutral, JVM

The main method is the entry point, where the program __.

begins execution.

A _ is a group of statements surrounded by braces

block

Every method has a _ that groups the statements in the method.

block (method block)

If there aren't any syntax errors, the compiler generates a _

bytecode file (with a .class extension)

what is this: /* This application program displays Welcome to Java! */

block / paragraph comment.

Run _ to get welcome result

bytecode

To execute a Java program is to run the program's _

bytecode

"Every class is compiled into a _ that has the same name as the class and ends with the .class extension."

bytecode file (separate for each)

Every class has a _ that groups the data and methods of the class.

class block

Every Java program is a set of _. The keyword class introduces a class definition. The contents of the class are included in a _.

class definitions, block

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 violates a rule—for example, if the semicolon is missing, a brace is missing, a quotation mark is missing, or a word is misspelled—the _ will report syntax errors.

compiler

Bytecode

generated by compiler for JVM to read & interpret

The Java language is a _ language, but Java bytecode is a _ language.

high level, low level

Instead of using the JDK, you can use a Java development tool (e.g., NetBeans, Eclipse, and TextPad)—software that provides an

IDE (for developing Java programs quickly)

the software for developing and running Java programs

JDK

the software for developing and running Java programs.

JDK

Java was developed by a team led by _

James Gosling

Java version: to develop server-side applications, such as Java servlets, JavaServer Pages (JSP), and JavaServer Faces (JSF).

Java EE

Java version: to develop applications for mobile devices, such as cell phones.

Java ME (Micro)

Java version: to develop client-side applications. The applications can run standalone or as applets running from a Web browser.

Java SE

What command is used to run a Java program?

java

To compile a Java source-code file from the command line, use

javac

What command is used to compile a Java program?

javac

Compile then run welcome to Java

javac Welcome.java, java Welcome

compile source code for welcome (instruction: __) to create _

javac welcome.java, Bytecode

In addition to line comments (beginning with //) and block comments (beginning with /*), Java supports comments of a special type, referred to as _ comments

javadoc

javadoc comments can be extracted into an HTML file using the JDK's _ command.

javadoc


संबंधित स्टडी सेट्स

Cognitive Psychology Exam 2 (chapters 5-8)

View Set

History of Rock and Roll: Final Review

View Set

Consumer Surplus and Producer Surplus

View Set

PHARM CH 40 - DRUG THERAPY FOR DIARRHEA

View Set

Ultrasound Physics CH 2 Questions

View Set

Perry Ch 40 The Child With Respiratory Dysfunction

View Set