• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
Front

How to study your flashcards.

Right/Left arrow keys: Navigate between flashcards.right arrow keyleft arrow key

Up/Down arrow keys: Flip the card between the front and back.down keyup key

H key: Show hint (3rd side).h key

image

PLAY BUTTON

image

PLAY BUTTON

image

Progress

1/150

Click to flip

150 Cards in this Set

  • Front
  • Back
OOP

Java was developed in 1990 by
Object-oriented programming
software development methodology in which a program is conceptualized as a group of objects that worked together

James Gosling
What are objects created from

What are objects
classes

self-contained element of a computer program that represents a related group of features and is designed to accomplish specific tasks
instantiation (def)
the process of creating an object from a class is called instantiation, which is why objects also are called instance
attributes (def)
are the data that differentiates one object from another. They can be used to determine the appearance, state, and other qualities of objects that belong to that class
instance variable (def)
used to define an object's attribute

objects store their individual states in "non-static fields", that is, fields declared without the static keyword.
Non-static fields are also known as instance variables because their values are unique to each instance of a class (to each object, in other words); the currentSpeed of one bicycle is independent from the currentSpeed of another.
object variables
---------------------------
All objects in Java are sub classes of the
instance variables
---------------------------
Object class
class variable
defines the attribute of an entire class
behavior
refers to the things that a class of objects can do to themselves and other objects
methods
groups of related statements in a class that perform a specific task
instance methods
usually called just methods, are used when you are working within an object of the class
method to display the values
System.out.println("");
inheritance (def)
------------------------------------------------------------
inheritance (code)
------------------------------------------------------------
Can classes inherit from more than one class in Java?
is a mechanism that enables one class to inherit all the behavior and attributes of another class
------------------------------------------------------------
public class ErrorCorrectionModem extends Modem {
// program goes here
}
------------------------------------------------------------
It’s possible with some programming languages (such as C++), but not in Java.
subclass (def)
a class that inherits from another class
superclass (def)
class that gives the inheritance is called a superclass
Class that sits on top of all Java class hierarchy
Object
subclassing (def)
is the creation of a new class that inherits from an existing class. The subclass is to indicate the differences in behavior and attributes between itself and its superclass
overriding (def)
you can create a method in a subclass that prevents a method in a superclass from being used.
To do this, you give the method with the same name, retunr type, and argument as the method in the superclass
single class inheritance (def)
java's form of inheritance is called single inheritance because each java class can have only one superclass
multiple inheritance (def)
c++
classes can have more than one superclass, and they inherit combined variables and methods from all those superclasses
interface (def)

What Is an Interface? Code
collection of methods that indicate a class has some behavior in addition to what it inherits from its superclasses

In its most common form, an interface is a group of related methods with empty bodies. A bicycle's behavior, if specified as an interface, might appear as follows:

interface Bicycle {
void changeCadence(int newValue);
void changeGear(int newValue);
void speedUp(int increment);
void applyBrakes(int decrement); }

To implement this interface, the name of your class would change (to a particular brand of bicycle, for example, such as ACMEBicycle), and you'd use the implements keyword in the class declaration:

class ACMEBicycle implements Bicycle {
// remainder of this class implemented as before
}
packages (def)

What Is a Package?
in java are way of grouping related classes and interfaces
group of related classes that serve a common purpose. An example is the java.util package

Packages enable groups of classes to be available only if they are needed ad eliminate potential conflicts among class names in different groups of classes

A package is a namespace that organizes a set of related classes and interfaces
to what package have java classes access to
java.lang package
statement (def)

protected variable (def)
is a simple command that causes something to happen

You can use a protected variable only in the same class as the variable, any subclasses of that class, or classes in the same package.
expression (def)
is a statement that produces a value
return value (def)
the value produced by a statement
statement between { and }
called a block statement
variables in java list
instance variables
class variables
local variables
instance variable (def)
used to define an object's attribute

objects store their individual states in "non-static fields", that is, fields declared without the static keyword.
Non-static fields are also known as instance variables because their values are unique to each instance of a class (to each object, in other words); the currentSpeed of one bicycle is independent from the currentSpeed of another.
local variables (def)
used inside method definitions can use only while the method or block is being executed by the java interpreter

Similar to how an object stores its state in fields, a method will often store its temporary state in local variables. The syntax for declaring a local variable is similar to declaring a field (for example, int count = 0;). There is no special keyword designating a variable as local; that determination comes entirely from the location in which the variable is declared — which is between the opening and closing braces of a method. As such, local variables are only visible to the methods in which they are declared; they are not accessible from the rest of the class.
main statement is the entry point to most Java programs. The most common exceptions are (2 list)

applet def
1)applets - programs that are run as part of a web
page
2)servlets - programs run by a web server
----------------------------------------------------------
A Java program that runs as part of a web page is called an applet
getting user input basic syntax
import java.util.Scanner;

class apples P
public static void main(String argsp[}){
Scanner bucky = new Scanner(System.in);
System.out.println(bucky.nextLine());
}
}
==
equals(b)
!=
(def)
== compares references, not values
equals(b) Compares values for equality
!= not equal
Random generation
(cmd)
import java.util.Random;
class diceRandom {
public static void main(STring[] args) {
Random dice = new Random();
int number;
for (int counter=1; counter<= 10; counter++) {
number = 1+dice.nextInt(6);
System.out.println(number + "" "");
} } }
prints a line
(cmd)

concat strings
System.out.println(number + " ");

+
imports scanner so we can read user input (cmd)
import java.util.Scanner
default class (cmd)

scanner class usages (cmd)
public static void main (String args[])

Scanner scanMe = new Scanner(System.in);
import java.util.Scanner
(full example)
imports scanner
import java.util.Random;
class readScanner {
public static void main(STring[] args) {
Scanner scanMe = new Scanner(System.in);
System.out.println(scanMe);
}
}
}
scanner class usages
(cmd)
Scanner scanMe = new Scanner(System.in);
nextLine();
used for inputting stirng
--------------------------------
import java.util.Random;
class readScanner {
public static void main(STring[] args) {
Scanner scanMe = new Scanner(System.in);
String Str = scanMe.nextLine();
} } }
loop through a two dimensional array
"for (int row=0;row<x.lenght; row++)
for (int column=0;column<x[row].lenght; column++)
{}"
function with unkown amount of parameters
public static int average(int...number) {
int total=0;
for (int x:numbers)
total+=x;
return total/numbers.lenght;
}
enchanced loop example
class enchancedFor {
public static void main (String[] args) {
int bucky[] = { 3,4 }'
int total = 0;

for ( int x: bucky ){
total = total + x;
} } }
arrays as parameter for methods
public static void change (int arr[])
initialize multidimensional array
int arr[][] = {{8,9,10,11},{-11,-12,-13}}
pritn a decimal by aways using two digits
String.format("%02d");
java integer types
byte 1 byte - -128 to 127
short 2 bytes - -32,768 - 32,767
int 4 bytes - -2,147,483,648 - 2,147,483,647
long 8 bytes - -9.10^18 to 9.10^18
float in java precision
double
float 1.4e - 45 to 3.4+38
double 4.9e - 323 to 1.7e+308
How you differentate between the variable and the equivalent classes
variable types are listed in lower case
classes share the same name but with capitalized first letter
keyword for defining constants
final
final int left = 4;
literals (def and exmp)
you can work with values as literals in Java statment. It is any number, text, or other information that directly represnts a value

int year = 2007;
integer literals
an interger literal that an int can hold is automaticly considered to be of the type long
how you indicate long for a literal
using the letter L

pennytotal = pennytotal + 4L;
how you indicate float point literals
use a period character .

double myGPA = 2.25;
of what type are float literals considere by defaul
double
to change to float add letter F

float piValue = 3.14115927;
character literals
a single char surrounded by quotation mark such as 'a', '$'
new char
tab char
backspace
carriage return
formfeed
\n - new char
\t - tab char
\b - backspace
\r - carriage return
\f - formfeed
backslash
single quotation mark
double quotation mark
octal
hex
unicode
\\ - backslash
\' - single quotation mark
\" - double quotation mark
\d -octal
\xd - hex
\ud - unicode
enum (def)
An enum type is a type whose fields consist of a fixed set of constants. Common examples include compass directions (values of NORTH, SOUTH, EAST, and WEST) and the days of the week.
public enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
THURSDAY, FRIDAY, SATURDAY
}
public class EnumTest {
Day day;
//we can use enum day in the class
}
enum range
public enum fish {
tuna("tasty", "2"),
salmon("nice", "3",
flander("no like", "22"),
snapper("not", "30"),
eel("i like", "10");

private final String desc;
private final String popular;
//missing in this example are 2 methods for getting value of class members
}
....some where in main class...
for (fish people: EnumSet.range (fish.tuna, fish.flander))
{
System.out.printf("%s\t%s", people, people.getDesc(), people.getPop()); } }
before we use enumaration we need to import

java built class for GUI componets
import java.until.EnumSet;

import javax.swing.JOptionPane;
how to count how many time a class has been used
use static variable
pritn a decimal by aways using two digits
String.format("%02d");
floyd triangle code
int countLine = 0, totalMembers = 15, countLast = 1;
for (int i = 0; i < totalMembers;)
{ System.out.print("\n");
for ( countLine = 1; countLine < countLast; countLine++) {
System.out.print(i+1); i++;
} countLast++;
}
show a dialog box for entering text

show a message dialog
String fn = JOptionPane.showInputDialog("Enter first number!");

JOptionPane.showMessageDialog(null, sum, "Result", JOptionPane.PLAIN_MESSAGE);
convert sting to int
int num1 = Integer.parseInt(String);
What to import in order to use string

Length of a string what to do (example)
What to import in order to use string
import java.lang.String;
--------------------------------------------------
import java.lang.String;

Stirng s = null;
s.lenght();
JMX abbr and def
JMX - Java Management Extensions provides a standard way of managing resources such as applications, devices, and services.
JNDI abbr and def
JNDI - Java Naming and Directory Interface enables accessing the Naming and Directory Service such as DNS and LDAP.
JAXP abbr and def
JAXP - Introduces the Java API for XML Processing (JAXP) 1.4 technology.
JAXB abbr and def
JAXB - Introduces the Java architecture for XML Binding (JAXB) technology.
RMI abbr and def
RMI - The Remote Method Invocation API allows an object to invoke methods of an object running on another Java Virtual Machine.
In the Java prog language, all source code is first written in ___________ files ending with the ______ extension. Those source files are then compiled into _________ by the __________. A .class file does not contain code that is native to your processor; it instead contains ________________ the machine language of the Java Virtual Machine. The _________ launcher tool then runs your application with an instance of the Java Virtual Machine
plain text files
java extension
.class files
javac compiler
bytecodes
javac
data encapsulation def
Hiding internal state and requiring all interaction to be performed through an object's methods is known as data encapsulation
primitive data types
byte -128 to 127
short -32,768 to 32,767
int 2^32 - 2000 mil
long 2^64
float - 32 bit IEEE
double -64 bit IEEE
boolean
char
Literals - def & code
literal is the source code representation of a fixed value; literals are represented directly in your code without requiring computation. As shown below, it's possible to assign a literal to a variable of a primitive type:

boolean result = true;
char capitalC = 'C';
byte b = 100;
short s = 10000;
int i = 100000;
Integer Literals - def & code
An integer literal is of type long if it ends with the letter L or l; otherwise it is of type int. It is recommended that you use the upper case letter L because the lower case letter l is hard to distinguish from the digit 1.

// The number 26, in decimal
int decVal = 26;
// The number 26, in hexadecimal
int hexVal = 0x1a;
// The number 26, in binary
int binVal = 0b11010;
Floating-Point Literals
A floating-point literal is of type float if it ends with the letter F or f; otherwise its type is double and it can optionally end with the letter D or d.

The floating point types (float and double) can also be expressed using E or e (for scientific notation), F or f (32-bit float literal) and D or d (64-bit double literal; this is the default and by convention is omitted).

double d1 = 123.4;
// same value as d1, but in scientific notation
double d2 = 1.234e2;
float f1 = 123.4f;
Character and String Literals
Literals of types char and String may contain any Unicode (UTF-16) characters. If your editor and file system allow it, you can use such characters directly in your code. If not, you can use a "Unicode escape" such as '\u'

single quotes' for char
double quotes" for String literals
In Java SE 7 and later, any number of underscore characters (_) can appear anywhere between digits in a numerical literal
long creditCardNumber = 1234_5678_9012_3456L;
long socialSecurityNumber = 999_99_9999L;
float pi = 3.14_15F;
long hexBytes = 0xFF_EC_DE_5E;
long hexWords = 0xCAFE_BABE;
long maxLong = 0x7fff_ffff_ffff_ffffL;
byte nybbles = 0b0010_0101;
long bytes = 0b11010010_01101001_10010100_10010010;

You can place underscores only between digits; you cannot place underscores in the following places:

At the beginning or end of a number
Adjacent to a decimal point in a floating point literal
Prior to an F or L suffix
In positions where a string of digits is expected
Create an array with new

Alternatively, you can use the shortcut syntax to create and initialize an array
newArray = new int[10];

int[] anArray = {
100, 200, 300,
400, 500, 600,
700, 800, 900, 1000
};

int[] elfSeniority;
this create the array but doesn't not store any values in it
int[] elfSeniority = new int[250];
creates an array and sets aside space for the values that it holds
Copying Arrays
The System class has an arraycopy method that you can use to efficiently copy data from one array into another:

public static void arraycopy(Object src, int srcPos,
Object dest, int destPos, int length)
read user input (till enter is pressed)
import java.util.Scanner;
public class sampleScanner {
public static void main ( String args[] )
{ Scanner sampleScanner = new Scanner(System.in);
System.out.println(sampleScanner.nextLine()); }}
The term "instance variable" is another name for
The term "instance variable" is another name for
non-static field.
The term "class variable" is another name for
The term "class variable" is another name for
static field.
how to read a double
import java.util.Scanner;
..
Scanner container = new Scanner (System.in);
double firstNum;
System.out.println("Enter first number: ");
firstNum = container.nextDouble();
the structure of applets differs from application (list)
1)no main() block
2)has init() and paint()
how can you call a method from a class without first creating an instance of the class
if a method is declared with the static keyword, this method can be called without first creating an instance of the class.
That's because static methods are called from classes, not from objects
Java requires that each public class is stored in a ___________
separate file
Consider the following statements:
int x = 3;
int answer = x++ * 10;
You might expect it to equal 40
Correct is 30

This statement is equal to
int x = 3;
int answer = x++ * 10;
the following statement
int answer = x * 10;
x++;

When a postfixed operator is used on a variable inside an expression, the variable’s value doesn’t change until after the expression has been completely evaluated
When a postfixed operator is used on a variable inside an expression, the variable’s value doesn’t change until __________ the expression has been completely evaluated
after
Consider the following statements:
int x = 3;
int answer = ++x * 10;
This statement is equal to
int x = 3;
int answer = ++x * 10;
the following statement
x++;
int answer = x * 10;
constants in Java (naming convention and code rules)
naming convention capitalize letter

final int TOUCHDOWN = 6;

use keyword final
The following order is used when working out an expression (precedence)
1. Incrementing and decrementing take place first.
2. Multiplication, division, and modulus division occur next from left to right.
3. Addition and subtraction follow.
4. Comparisons take place next.
5. The equal sign (=) is used to set a variable’s value.
Evaluate
1)
int y = 10;
x = y * 3 + 5;

2)
int x = 5;
int number = x++ * 6 + 4 * 10 / 2;
1) x = 35
2) we use x++ which meant that x is evaluated after the expression multiplication and division are handled from left to right. First, 5 is multiplied by 6, 4 is multiplied by 10, and that result is divided by 2
int number = 30 + 20
Java uses letter after variables to declare type
float pi = 3.14F;

F - indicates float
L - long integers
D - double floating -poing

If letter is omited defaul is double.
Java 7 and _ for organazing number
long salary = 264400000;

long salary = 264_400_000;

The underscores are ignored, so the variable still equals the same value.
compound assignments (def)
You can also combine the arithmetic operators with the simple assignment operator to create compound assignments. For example, x+=1; and x=x+1; both increment the value of x by 1.
instanceof operator (def)
instanceof operator compares an object to a specified type. You can use it to test if an object is an instance of a class, an instance of a subclass, or an instance of a class that implements a particular interface.
Consider the following code snippet:
int i = 10;
int n = i++%5

What are the values of i and n after the code is executed?
------------------------------------------------------------------------------
int i = 10;
int n = i++%5;
What are the values of i and n after the code is executed?
i is 11, and n is 0.
------------------------
i is 11, and n is 1.
enhanced for statement
class EnhancedForDemo {
public static void main(String[] args){
int[] numbers =
{1,2,3,4,5,6,7,8,9,10};
for (int item : numbers) {
System.out.println("Count is: " + item);
}
}
}
labeled break terminates the outer for loop (labeled "search")
search:
for (i = 0; i < arrayOfInts.length; i++) {
for (j = 0; j < arrayOfInts[i].length;
j++) {
if (arrayOfInts[i][j] == searchfor) {
foundIt = true;
break search;
} } }

unlabeled break statement terminates the innermost switch, for, while, or do-while statement, but a labeled break terminates an outer statement
continue statement
kips the current iteration of a for, while , or do-while loop. The unlabeled form skips to the end of the innermost loop's body and evaluates the boolean expression that controls the loop
steps through a String, counting the occurences of the letter "p". If the current character is not a p, the continue statement skips the rest of the loop and proceeds to the next character. If it is a "p", the program increments the letter count.
String searchMe = "peter piper picked a " + "peck of pickled peppers";
int max = searchMe.length();
int numPs = 0;

for (int i = 0; i < max; i++) {
// interested only in p's
if (searchMe.charAt(i) != ' ) continue;
// process p's
numPs++;
}
System.out.println("Found " + numPs + " p's in the string.");
labeled continue statement skips the current iteration of an outer loop marked with the given label.
String searchMe = "Look for a substring in me";
String substring = "sub";
boolean foundIt = false;
int max = searchMe.length() - substring.length();
test:
for (int i = 0; i <= max; i++) {
int n = substring.length();
int j = i;
int k = 0;
while (n-- != 0) {
if (searchMe.charAt(j++) != substring.charAt(k++)) {
continue test;
}
}
foundIt = true;
break test;
}
System.out.println(foundIt ? "Found it" : "Didn't find it");
class declaration short
-------------------------------
class declaration full (without modifiers)
class MyClass {
// field, constructor, and
// method declarations
}
--------------------------------------
class MyClass extends MySuperClass implements YourInterface {
// field, constructor, and
// method declarations
}
Access Modifiers list
public modifier—the field is accessible from all classes.
private modifier—the field is accessible only within its own class.
typical method declaration
public double calculateAnswer(double wingSpan, int numberOfEngines,
double length, double grossTons) {
//do the calculation here
}
method signature def
the method's name and the parameter types
overloading methods def
Java can distinguish between methods with different method signatures. This means that methods within a class can have the same name if they have different parameter lists
class contains constructors def
class contains constructors that are invoked to create objects from the class blueprint. Constructor declarations look like method declarations—except that they use the name of the class and have no return type.
public Bicycle(int startCadence, int startSpeed, int startGear) {
gear = startGear;
cadence = startCadence;
speed = startSpeed;
}
To create a new Bicycle object called myBike, a constructor is called by the new operator:
Bicycle myBike = new Bicycle(30, 0, 8);
You can have multiple constructors as long as they have diff. argument list
You don't have to provide any constructors for your class, but you must be careful when doing this. Because....
The compiler automatically provides a no-argument, default constructor for any class without constructors. This default constructor will call the no-argument constructor of the superclass. In this situation, the compiler will complain if the superclass doesn't have a no-argument constructor so you must verify that it does. If your class has no explicit superclass, then it has an implicit superclass of Object, which does have a no-argument constructor.
example of a method that accepts an array as an argument
public Polygon polygonFrom(Point[] corners) {
// method body goes here
}
construct called varargs def
to pass an arbitrary number of values to a method. Use when you don't know how many of a particular type of argument will be passed to the method
To use varargs, you follow the type of the last parameter by an ellipsis (three dots, ...), then a space, and the parameter name. The method can then be called with any number of that parameter, including none.
public Polygon polygonFrom(Point... corners) {
int numberOfSides = corners.length;
double squareOfSide1, lengthOfSide1;
squareOfSide1 = (corners[1].x - corners[0].x)* (corners[1].x - corners[0].x)+ (corners[1].y - corners[0].y)* (corners[1].y - corners[0].y);
lengthOfSide1 = Math.sqrt(squareOfSide1);
}
You can see that, inside the method, corners is treated like an array. The method can be called either with an array or with a sequence of arguments.
You will most commonly see varargs with the printing methods; for example
public PrintStream printf(String format, Object... args)
allows you to print an arbitrary number of objects. It can be called like this:
System.out.printf("%s: %d, %s%n", name, idnum, address);
or like this
System.out.printf("%s: %d, %s, %s, %s%n", name, idnum, address, phone, email);
Parameter Names
When you declare a parameter to a method or a constructor, you provide a name for that parameter. This name is used within the method body to refer to the passed-in argument.
Shadowing fields can make your code difficult to read.
A parameter can have the same name as on the class's fields. How is this called?
public class Circle {
private int x, y, radius;
public void setOrigin(int x, int y) {
...
}
}
Passing Primitive Data Type Arguments
Primitive arguments, such as an int or a double, are passed into methods by value
This means that any changes to the values of the parameters exist only within the scope of the method.
public class PassPrimitiveByValue {
public static void main(String[] args) {
int x = 3;
// invoke passMethod() with x as argument
passMethod(x);
// print x to see if its value has changed
System.out.println("After invoking passMethod, x = " + x);
} // change parameter in passMethod()
public static void passMethod(int p) {
p = 10;
} }
When you run this program, the output is:
After invoking passMethod, x = 3
Passing Reference Data Type Arguments
Reference data type parameters, such as objects, are also passed into methods by value.
This means that when the method returns, the passed-in reference still references the same object as before. However, the values of the object's fields can be changed in the method, if they have the proper access level.
public void moveCircle(Circle circle, int deltaX, int deltaY) {
// code to move origin of circle to x+deltaX, y+deltaY
circle.setX(circle.getX() + deltaX);
circle.setY(circle.getY() + deltaY);
// code to assign a new reference to circle
circle = new Circle(0, 0); }
Let the method be invoked with these arguments: moveCircle(myCircle, 23, 56)
Inside the method, circle initially refers to myCircle.
The method changes the x and y coordinates of the object that circle references (i.e., myCircle) by 23 and 56, respectively. These changes will persist when the method returns. Then circle is assigned a reference to a new Circle object with x = y = 0. This reassignment has no permanence, however, because the reference was passed in by value and cannot change. Within the method, the object pointed to by circle has changed, but, when the method returns, myCircle still references the same Circle object as before the method was called.
Java 7 adds support for using _________ as the test variable in a switch-case statement. (Java 7 and switch)
..
String command = “BUY”;
..
switch (command) {
case “BUY”:
quantity += 5;
balance -= 20;
break;
case “SELL”:
quantity -= 5;
balance += 15;
}
Enable Java 7 support for a project
1)Projects pane, right-click your project
2)click Properties from pop-up menu
3)Project Properties dialog opens
4)In the Categories pane, click Sources
3)In the Source/Binary Format drop-down, choose JDK7
ternary operator def
int numberOfEnemies = (skillLevel > 5) ? 10 : 5;
ternary expression has five parts:
. The condition to test, surrounded by parentheses, as in (skillLevel > 5)
. A question mark (?)
. The value to use if the condition is true
. A colon (:)
. The value to use if the condition is false
get current time and date
Calendar now = Calendar.getInstance();
int hour = now.get(Calendar.HOUR_OF_DAY);
int minute = now.get(Calendar.MINUTE);
int month = now.get(Calendar.MONTH) + 1;
int day = now.get(Calendar.DAY_OF_MONTH);
int year = now.get(Calendar.YEAR);
Why are interpreted languages slower than compiled ones?
the interpreter needs to work with the code as a whole and take shortcuts to speed up the process
compiled languages can be much faster than interpreted languages because they do things to make the program run more efficiantly
Interpreted language
are programming language in which programs are 'indirectly' executed ("interpreted") by an interpreter program
BASIC, JS, Perl, PHP, Ruby
Interpreted language advantages
1)platform independence (Java's byte code, for example)
2)reflection and reflective use of the evaluator (e.g. a first-order eval function)
3)dynamic typing
4)smaller executable program size (since implementations have flexibility to choose the instruction code)
5)dynamic scoping
reflection in computer science
the ability of a computer program to examine and modify the structure and behavior of an object at a runtime.
Used mostly in high level VM programming languages also in scripting languages
compiled language
compiled language is a programming language whose implementations are typically compilers (translators which generate machine code from source code), and not interpreters (step-by-step executors of source code, where no translation takes place).

The term is somewhat vague; in principle any language can be implemented with a compiler or with an interpreter. A combination of both solutions is also increasingly common: a compiler can translate the source code into some intermediate form (often called bytecode), which is then passed to an interpreter which executes it.

A program translated by a compiler tends to be much faster than an interpreter executing the same program: even a 10:1 ratio is not uncommon

C++, C#
Requirements for Java program name
Java program must have a name that matches the
first part of its filename and should be capitalized the same way.
in Netbeans how to specify argument for the program that is expecting command line parameters
1)Choose the menu command Run, Set Project Configuration, Customize. The Project Properties dialog opens.
2)In the Arguments field, enter arguments
3)Change the main Class text field if needed
Sample applet
import java.awt.*;

public class RootApplet extends javax.swing.JApplet {
int number;
public void init() { number = 225; }

public void paint(Graphics screen) {
Graphics2D screen2D = (Graphics2D) screen;
screen2D.drawString("The square root of " + number + " is " + Math.sqrt(number), 5, 50); } }
Do all arguments sent to a Java application have to be strings?
Java stores all arguments as strings when an application runs. When you want to use one of these arguments as an integer or some other nonstring type, you have to convert the value.
list of java primitive data type (8)
byte - 8 bit - from -128 to 127
short - 16 bit - from -32,678 to 32,677
int - 32 bit - from -2,147,483,648 to 2,147,483,647
long - 64 bit - from -9.22
quintillion to 9.22 quintillion

float - 32 bit
double - 64 bit

boolean - true/false
char - 16 bit unicode char
command displays a string in console app
----------------------------
string vs char
----------------------------
escape quotes in Java
System.out.println(weight);
----------------------------
"String" - string
'C' - char
----------------------------
System.out.println(“Jane Campion directed \”The Piano\” in 1993.”);
Can I specify integers as binary values in Java?
You can for the first time in Java 7. Put the characters 0b in front of the number and follow it with the bits in the value. Because 1101 is the binary form for the number 13, the following statement sets an integer to 13:
int z = 0b0000_1101;
The underscore is just to make the number more readable. It’s ignored by the Java compiler.
Special Characters

Single quotation mark
Double quotation mark
Backslash
Tab
\' - Single quotation mark
\" - Double quotation mark
\\ - Backslash
\t - Tab
Special Characters

Backspace
Carriage return
Formfeed
Newline
\b - Backspace
\r - Carriage return
\f - Formfeed
\n - Newline
Nimbus def
Java 7 introduces an enhanced look and feel called Nimbus, but it must be turned on to be used in a class

UIManager.setLookAndFeel(
“com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel”
);
Includes for using Swing
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
Java is flexible about where the
square brackets are placed
when an array is being created
--------------------------------
following example creates an array of strings and gives them initial values:
String niceChild[];
String[] naughtyChild;
--------------------------------
String[] reindeerNames = { “Dasher”, “Dancer”, “Prancer”, “Vixen”,
“Comet”, “Cupid”, “Donder”, “Blitzen” };
create an array that has two dimensions
--------------------------------
Sorting an array is easy in Java because the Arrays class does all of the work. Arrays, which is part of the _______
boolean[][] selectedPoint = new boolean[50][50];
--------------------------------
java.util group of classes
import java.util.* statement to make all the java.util classes available in the program
The letters that appear most often in English are
---------------------------------
toCharArray() method
E, R, S, T, L, N, C, D, M, and O, in that order.
-----------------------------------------
When you’re working with strings, one useful technique is to put each character in a string into its own element of a character array. To do this, call the string’s toCharArray() method, which produces a char array with the same number of elements as the length of the string.
In a multidimensional array, is it possible to use the length variable to measure different dimensions other than the first?
Yes
1st dimension data.length
2nd dimension data[0].length
3nd dimension data[0][0].length
casting (def)
------------------
statements cast a float value into an int:
Converting information to a new form is called casting. Casting produces a new value that is a different type of variable or object than its source
-------------------------
float source = 7.06F;
int destination = (int) source;
When you are converting information from a larger variable type into a smaller type, you must explicitly cast it, as in the following statements
int xNum = 103;
byte val = (byte) xNum;
Casting Objects
You can cast objects into other objects when the source and destination are
related by inheritance. One class must be a subclass of the other.

To use an object in place of one of its subclasses, you must cast it explicitly
with statements such as the following:
Graphics comp = new Graphics();
Graphics2D comp2D = (Graphics2D) comp;
There are classes in Java for each of the simple variable types
---------------------------------------------
following statement creates
an Integer object with the value 5309:
Boolean, Byte, Character, Double, Float, Integer, Long, and Short
----------------------------
Integer suffix = new Integer(5309);
Integer suffix = new Integer(5309);

To get an int value from the
preceding suffix object, the following statement could be used:
int newSuffix = suffix.intValue();
When the string’s value could become an integer, this can be done using the
parseInt()

String count = “25”;
int myCount = Integer.parseInt(count);
How to add a cmd line argument to project in NetBeans?
Run, Set Project Configuration, Customize. The Project Properties window opens.
Enter <name of the class> as the Main Class and 169 in the Arguments field.
Java’s autoboxing and unboxing capabilities
Java’s autoboxing and unboxing capabilities make it possible to use the basic data type and object forms of a value interchangeably.

Autoboxing casts a simple variable value to the corresponding class.

Unboxing casts an object to the corresponding simple value.
JApplet has _____ superclasses above it in the hierarchy + list
5
Applet
Panel
Container
Component
Object