Sie sind auf Seite 1von 12

What is a bit What is a byte What are native compilers What are java programs compiled into What

are java bytecodes the machine language for What is a java virtual machine What is the basic building block of all java programs What is needed to execute java bytecodes What does API stand for What file extension must be used for the files where java code is entered What file extension is use for compiled java bytecodes What is the console window Should the name of each java class be capitalized What is the 1st line of a class What must the name of a java code file be What is a method What is the method header for the main method What is the one method every java program must have Can string literals span more than one line in java programs How can you print a blank line of output in java What are escape sequences What are identifiers What must identifiers start with Which characters can be used in identifiers Should the names of methods begin with an uppercase letter How should a method with multiple words in its name be capitalized How should a constant name with multiple words be capitalized What are the 2 comment forms java supports Which error is the most important when multiple compile error messages occur Which programming languages focus on actions or verbs Which programming languages are noun-oriented What is iterative enhancement What does programming in java involve What is a static method What is the template for a method header What does the void keyword in a method header mean Does the main method have to be the 1st method in a class What are the 4 fundamental primitive data types What are the 2 kinds of data in java What is an expression What are operands What is an integer literal What is a floating point literal What are character literals What are boolean literals How can you test whether a number is even or odd What is the formula that expresses how the modulus operator works

How can you find the final digit in a number How can you find the last 4 digits of a social security number How does integer division work in java Can the modulus operator be used with doubles as well as integers What is the order of precedence for unary, additive and multiplicative operators How are operators evaluated if they are all at the same level of precedence When does java use integer (truncating) division When does java do real-valued (normal) division How can you cast a double to an int value What happens when you cast a double to an int What does every value of type char have How do you cast a double expression to int What is a variable What is the naming convention for variable names in java What is a variable declaration How can you print the value of a variable How does the assignment operator = evaluate an expression How many values can you pass to System.out.println What is string concatenation often used for What does X += 1; mean What does X -= 2; mean What does X *= 3; mean What does X /= 4 mean What does X++ mean What does Y-- mean What does ++X mean What precedence do the assignment operators =, +=, -=, /=, *= %= have Can you assign a double variable an integer value Can you assign an integer variable a double value What is the convention for control variables in for loops When must you use curly braces with a for loop How is System.out.println different from System.out.print What does System.out.println(); do What is the scope of a static method What is the scope of a variable What is a local variable Why should you declare variables in the most local scope possible Can you use the same variable name in multiple for loops What is the scope of a variable declared in the intialization part of a for loop What is a constant What is the scope of a constant Can static methods access constants How can you read strings from the console window How can you read a double value from the console window How can you read an integer from the console window How can you read the next line of input as a string from the console window What is whitespace

What can be changed when you pass an object as a parameter In which package is the Scanner object located How can you construct a Scanner object to read from the console window What is a token What do primitive variables store What do object variables store What is value semantics What is refernce semantics What is the default constructor What is the naming convention for constructors What is a package What is an import declaration Which classes does java automatically import What is the syntax for an import declaration What happens when an exception is thrown What is a stack trace What is an immutable object What is a constructor How are constructors called What is an algorithm Are object names capitalized or all lower case How do you call an object's method How can you determine that character at a specific position in a string When do you test for loops with < What are exceptions What is method overloading How does method overloading work if multiple methods each have only one parameter How do you call a method that is in another class How can you tell the type of value a method returns What must be the last statement in a method What is an object How many parameters can a method have What must each method call with parameters provide How should method headers with many parameters be written When should you use a class constant rather than a parameter What is a method signature What is a parameter How is a parameter indicated in a method header What is a formal parameter What is an actual parameter What happens when a parameter is passed to a method When should you nest if statements When should you use sequential if statements What is the algorithm for the fencepost problem How is the fencepost algorithm solved What is the algorithm to find the sum of a series of numbers What is the algorithm to find the product of a series of numbers

What is the syntax for the simple if statement When should you use the simple if statement What is the syntqax for the if-else statement When should you use the if else statement What precedence do equality operators have What precedence do the relational operators <, >, <=, >= have What is the limitation of the relational operators What does NaN mean What is the syntax for the fencepost with if algorithm Which if statement should be used when you want to execute any combination of controlled statements Which if statement should be used if you want to execute zero or one of the controlled statements Which if statement should be used if you want to execute exactly one of the controlled statements How can you test objects to determine if they store equivalent values Which method is used to determine equality of strings while disregarding case What are roundoff errors When do roundoff errors occur Which type of variables cannot be compared to determine equality How can you test equality as a close match between double values What is factoring with respect to if/else statements How can you factor if/else statements What is the syntax to compute the maximum of a sequence of values How should a maximum loop be initialized What should a minimum loop be initialized to What are the advantages of using char values over string values What is the bridge between the data types String and char Does every integer have a corresponding char value Is it necessary to cast char values to int Do you have to cast an integer value to char explicitly What is System.out.printf used for What is the syntax for the System.out.printf method Does System.out.printf move to a new line automatically like System.out.println How many format specifiers can you have in a System.out.printf statement What are preconditions What is a post condition What does int x = 1/0; produce What happens when you type in double x = 1.0 / 0.0 What do floating point numbers follow When should you throw an exception Are exceptions considered to be objects What must you do before you can throw an exception What happens when an exception is thrown If a method returns a value, what must your code guarantee What should you do when you are programming a formula

a single binary digit 8 bits a compiler that translates code directly into machine language java bytecodes java virtual machine a theoretical computer whose machine language is the set of java bytecodes class java runtime environment application programming interface .java .class a text-only window in which java programs interact with the user yes class header the same as the class name a single action or calculation to be performed public static void main (String args [] ) main () no System.out.println(); 2 character sequences used to represent special characters names given to an entity in a program such as a class or method a letter 1.) letters 2.) numbers 3.) underscore 4.) dollar sign no - always lowercase 1.) 1st word should start with a lowercase letter 2.) subsequent words should be capitalized 1.) all uppercase letters 2.) words should be separated by underscores 1.) /* */ multiple-line comments 2.) // single-line comments the 1st error reported by the compiler procedural programming languages like C object-oriented languages like java the process of producing a program in stages adding new functionality at each stage decomposing a problem into various objects - each with methods that perform specific tasks a block of java statements that is given a name public static void < name > {} the method executes statements but does not produce any value no - it should be either the first or the last method 1.) int 2.) double 3.) char 4.) boolean 1.) primitive 2.) objects a simple value or a set of operations that produces a value ie 72 or (2 * 6) 7 + 29 the 7 and 29 are operands a sequence of digits with or without a leading sign ie 482 or -2944 digits that include a decimal point 298.4 207. 0.284 one character enclosed in single quotes ie 'a' '\\' 1.) true 2.) false 1.) number % 2 is 0 for evens 2.) number % 2 is 1 for odds x % y = x - (x/y) * y

number % 10 number % 10000 if both operands are integers java truncates the answer after the decimal point ie 19/5 = 3.8 but is 3 in java yes unary operators are the highest, multiplicative operators including % are next, additive operators are the lowest from left to right if the two operands are both of type int if either of the two operands is of type double (int) 4.75 java truncates anything after the decimal point ie (int) 4.75 is 4 a corresponding integer value (int) (2.5/0.15) not (int) 2.5/0.15 a memory location with a name and a type that stores a value start variable names with a lowercase letter and capitalize any subsequent words ie NumberOfDigits a request to set aside a new variable with a given name and type double height = 70; System.out.println(height); from right to left only one to report the value of a variable X = X + 1; X = X - 2; X = X * 3; X = X / 4; X = X + 1; Y = Y - 1; increment by one, then give me X lower priority than the additive operators yes no names like I, j and k are often used (for I = 0; I < 6; i++) when you have more than one statement that you want the loop to control System.out.println() sends output to the current line and then moves to the beginning of the next line, System.out.print does it positions the cursor at the beginning of the next line the entire class in which it appears from the point it is declared to the right curly brace that encloses it a variable declared inside a method that is accessible only in that method to provide more security yes - as long as the for loops are not nested just the for loop itself a named value that cannot be changed by the program the entire class in which it is declared only if the constants are declared as static ie public static final int LINEs = 5; String s = console.next(); double temperature = console.nextDouble(); int age = console.nextInt(); String s = console.nextLine(); 1.) spaces 2.) tab characters '\t' 3.) newline characters '\n'

you can change the object itself - you can't change the variable that points to the object java.util.*; Scanner console = new Scanner (System.in); A single element of input ie one word, one number the actual data ie 8, 4.3, '\n' the variable stores a reference to where the objct is stored - the actual data is stored in the object a system in which values are stored directly - copying involves the creation of independent copies of values a syste in which references to values are stored - copying involves copying references a zero-argument constructor they always have the same name as the class a collection of related java classes a request to access a specific java package every class stored in java.lang.*; import java.awt.*; if you have not written code to handle the error - execution is halted and a stack trace will display a series of methods that have been called in reverse order - this occurs when an exception is thrown an object that once constructed, their value cannot be changed a method that creates and intializes an object use the new keyword followed by the object's type and any parameters Point g = new Point(2,8); a step by step description of how to accomplish a task the first letter of an object name is always capitalized write the name of the varible, then a dot, then the name of the method, ie String s = "hello"; s.length(); s1.charAt(7); when loops start at zero use < less than when loops start at one use <= less than or equal to a runtime error that prevents a program from continuing its normal execution the ability to define 2 or more different methods with the same name but different method signatures the parameters can be different data types ie 1.) String 2.) int 3.) double <class name>.element so to call the sqrt method in java.math double root = Math.sqrt(i); public static double sqrt(double n); the word after "public static" indicates the return type of the method the return statement a programming entity that contains 1.) state - data 2.) behavior - methods as many as you like the exact number of parameters in the same order as defined in the method signature insert a line break after a parameter and indent the following line by 2x the normal indentation width use a class constant when you only want to change the value from execution to execution - if you want to use different value the name of a method along with its number and type of parameters any characteristic that distinguishes different members of a family of tasks public static void writeSpaces (int number) {} the parameter name and type are placed inside the parentheses a variable that appears inside parentheses in the header of a method ie public static void writeSpaces(int number) a specific value or expression that appears inside parentheses in a method call ie public static void writeSpaces(42); a local variable is created - it is a copy of the value coming from outside the method when you only want to execute one of a series of statements when you want to execute any combination of total number of statements plant a post, for (the length of the fence) { attach some wire plant a post } by planting one of the posts either before or after the loop - usually the post is planted before you enter the loop sum = 0; for (all numbers to sum) { obtain the next number sum += next;} product = 1; for (all numbers to multiply) { obtain "next" product *= next; }

if (<test> ) { statement; statement; } when you have code that you want to execute sometimes and skip other times if (<test> ) { statement; statement; } else { statement; statement; } when you have 2 alternative courses of action and one of the actions should always be performed they have lower precedence then the relational operators but higher precedence than the assignment operators lower precedence than the additive operators but higher precedence than the equality operators they can only be used with primitive data - they cannot be used with objects not a number for (the length of the fence) { plant a post if(this isn't the last post) {attach some wire}} sequential if statements nested ifs that do not end with an else statement nested ifs that end with an else statement if( p1.equals (p2)) { System.out.println("points are equal"); if (s.equalsIgnoreCase("yes")) { processYes(); a numerical error that occurs because floating point numbers are stored as approximations rather than exact values when a floating point number has repeating digits when expressed in base 2 doubles if (Math.abs(dollar1 - dollar2) < .001) {} isolating commond pieces of code from the different branches of an if/else construct at both the top and bottom of each if/else branch initialize max for (all numbers to examine) { obtain "next" if(next > max) {max = next;}} initialize max either to the lowest possible value or to the first value read the highest possible value or to the first value 1.) chars can be used in simple arithmetic expressions and in loops 2.) char values can be compared using relationsl operator the String object's charAt() method - it accepts an integer index as a parameter and returns the character found at that index no no - java does that automatically yes to format print output System.out.printf(format string, parameters); no the # of format specifiers in the format string must match the # of parameters that follow it A condition that must be true before a method executes to guarantee that it can perform its task A condition that the method guarantees will be true after it finishes executing - as long as the preconditions were true before java throws a division by zero exception infinity a standard from IEEE that defines what should happen when a precondition fails yes construct an exception object using the keyword new it halts the execution of the method that every path through that method will return the correct value type, ie int, char etc create a method for the formula

, System.out.print does not move to the beginning of the next line

nt to use different values within a single execution, use a parameter

(int number) teSpaces(42);

ter the loop

n exact values

using relationsl operators <, == etc cter found at that index in the string

ditions were true before it was called

Das könnte Ihnen auch gefallen