AP Notes, Outlines, Study Guides, Vocabulary, Practice Exams and more!

Java Flashcards

Exam 1 (chapter 1-4)

Terms : Hide Images
3978073728These are words that have a special meaning in the programming language. o Punctuation o Programmer-defined names o Key words o OperatorsKey words0
3978073729These are symbols or words that perform operations on one or more operands. o Punctuation o Programmer-defined names o Key words o OperatorsOperators1
3978073730These characters serve specific purposes, such as marking the beginning or ending of a statement, or separating items in a list. o Punctuation o Programmer-defined names o Key words o OperatorsPunctuation2
3978073731These are words or names that are used to identify storage locations in memory and parts of the program that are created by the programmer. o Punctuation o Programmer-defined names o Key words o OperatorsProgrammer-defined names3
3978073732These are the rules that must be followed when writing a program. o Syntax o Punctuation o Key words o OperatorsSyntax4
3978073733This is a named storage location in the computers memory. o Class o Key word o Variable o OperatorVariables5
3978073734The Java compiler generates. o Machine code o Byte code o Source code o HTMLByte code6
3978073735Every complete statement ends with a ____. o Period o Parenthesis o Semicolon o Ending braceSemicolon7
3978073736The following data 72 , 'A' , "Hello World" , 2.8712 are all examples of ______. o Variables o Literals o Strings o None of theseLiterals8
3978073737A group of statements, such as the contents of a class or a method, are enclosed in _____. o Braces { } o Parentheses ( ) o Brackets [ ] o Any of these will doBraces { }9
3978073738Which of the following are NOT valid assignment statements? o Total = 9; o 72 = amount; o profit = 129 o letter = 'W';72 = amount; profit = 12910
3978073739Which of the following are not valid println statements? o System.out.println + "Hello World"; o System.out.println("Have a nice day"); o Out.System.println(value); o Println.out(Programming is great fun);System.out.println + "Hello World"; Out.System.println(value); Println.out(Programming is great fun);11
3978073740The negation operator is _____. o Unary o Binary o Ternary o None of theseUnary12
3978073741This key word is used to declare a named constant. o constant o namedConstant o final o concretenamedConstant13
3978073742These characters mark the beginning of a multi-line comment. o // o /* o */ o /**/*14
3978073743These characters mark the beginning of a single-line comment. o // o /* o */ o /**//15
3978073744These characters mark the beginning of a documentation comment. o // o /* o */ o /**/**16
3978073745Which Scanner class method would you use to read a string as input? o nextString o nextLine o readString o getLinenextLine17
3978073746Which Scanner class method would you use to read a double as input? o nextDouble o getDouble o readDouble o None of these; you cannot read a double with Scanner classnextDouble18
3978073747You can use this class to display dialog boxes. o JOptionPane o BufferedReader o InputStreamReader o DialogBoxJOptionPane19
3978073748When Java converts a lower-ranked value to a higher-ranked type, it is called a(n) _____. o 4-Bit conversion o Escalating conversion o Widening conversion o Narrowing conversionWidening conversion20
3978073749This type of operator lets you manually convert a value, even if it means that a narrowing conversion will take place. o Cast o Binary o Uploading o DotCast21
3978073750A left brace in a Java program is always followed by a right brace later in the program. o True o FalseTrue22
3978073751A variable must be declared before it can be used. o True o FalseTrue23
3978073752Variable names may begin with a number. o True o FalseFalse24
3978073753You cannot change the value of a variable whose declaration uses the final key word. o True o FalseTrue25
3978073754Comments that begin with // can be processed by javadoc. o True o FalseFalse26
3978073755If one of an operators operands is a double, and the other operand is an int, Java will automatically convert the value of the double to an int. o True o FalseFalse27
3978073756The if statement is an example of a _____. o Sequence structure o Decision structure o Pathway structure o Class structureDecision Structure28
3978073757This type of expression has a value of either true or false. o Binary expression o Decision expression o Unconditional expression o Boolean expressionBoolean expression29
3978073758> , < , and == are _____. o Relational operators o Logical operators o Conditional operators o Ternary operatorsRelational operators30
3978073759&& , || , and ! are _____. o Relational operators o Logical operators o Conditional operators o Ternary operatorsLogical operators31
3978073760This is an empty statement that does nothing. o Missing statement o Virtual statement o Null statement o Conditional statementNull statement32
3978073761To create a block of statements, you enclose the statement in these. o Parentheses ( ) o Square brackets [ ] o Angled brackets < > o Braces { }Braces { }33
3978073762This is a Boolean variable that signals when some condition exists in the program. o Flag o Signal o Sentinel o SirenFlag34
3978073763How does the character 'A' compare to the character 'B'? o 'A' is greater than 'B' o 'A' is less than 'B' o 'A' is equal to 'B' o You cannot compare characters'A' is less than 'B'35
3978073764This is an if statement that appears inside another if statement. o Nested if statement o Tiered if statement o Dislodged if statement o Structured if statementNested if statement36
3978073765An else clause always goes with _____. o The closest previous if clause that doesn't already have its own else clause o The closest if clause o The if clause that is randomly selected by the compiler o None of theseThe closest previous if clause that doesn't already have its own else clause37
3978073766When determining whether a number is inside a range, its best to use this operator. o && o ! o || o ? :&&38
3978073767This determines whether two different String objects contain the same string. o The == operator o The = operator o The equals method o The StringCompare methodThe equals method39
3978073768The conditional operator takes this many operands. o One o Two o Three o FourThree40
3978073769This section of a switch statement is branched to if none of the case expressions match the switch expression. o Else o Default o Case o OtherwiseDefault41
3978073770You can use this method to display formatted output in a console window. o Format.out.println o Console.format o System.out.printf o System.out.formattedSystem.out.printf42
3978073771The = operator and the == operator perform the same operation. o True o FalseFalse43
3978073772A conditionally executed block should be indented one level from the if clause. o True o FalseTrue44
3978073773All lines in a conditionally executed block should be indented one level. o True o FalseTrue45
3978073774When an if statement is nested in the if clause of another statement, the only time the inner if statement is executed is when the Boolean expression of the outer if statement is true. o True o FalseTrue46
3978073775When an if statement is nested in the else clause of another statement, the only time the inner if statement is executed is when the Boolean expression of the outer if statement is true. o True o FalseFalse47
3978073776The scope of a variable is limited to the block in which it is defined. o True o FalseTrue48
3978073777What will the println statement in the following program segment display? Int x = 5; System.out.println(x++); o 5 o 6 o 0 o none of these549
3978073778What will the println statement in the following program segment display? Int x = 5; System.out.println(++x); o 5 o 6 o 0 o none of these650
3978073779In the expression number++, the ++ operator is in what mode? o Prefix o Protest o Postfix o PosttestPostfix51
3978073780What is each repetition of a loop known as? o Cycle o Revolution o Orbit o IterationIteration52
3978073781This is a variable that controls the number of iterations performed by a loop. o Loop control variable o Accumulator o Iteration register variable o Repetition meterLoop control variable53
3978073782The while loop is this type of loop. o Pretest o Posttest o Prefix o PostfixPretest54
3978073783The do while loop is this type of loop. o Pretest o Posttest o Prefix o PostfixPosttest55
3978073784The for loop is this type of loop. o Pretest o Posttest o Prefix o PostfixPretest56
3978073785This type of loop has no way of ending and repeats until the program is interrupted. o Intermediate o Interminable o Infinite o TimelessInfinite57
3978073786This type of loop always executes at least once. o While o Do-while o For o Any of theseDo-while58
3978073787This expression is executed by the loop only once, regardless of the number of iterations. o Initialization expression o Test expression o Update expression o Pre-increment expressionInitialization expression59
3978073788This is a variable that keeps a running total. o Sentinel o Sum o Total o AccumulatorAccumulator60
3978073789This is a special value that signals when there are no more items from a list of times to be processed. This value cannot be mistaken as an item from the list. o Sentinel o Flag o Signal o AccumulatorSentinel61
3978073790To open a file for writing, you use the following class. o PrintWriter o FileOpen o OutputFile o FileReaderPrintWriter62
3978073791To open a file for reading, you use the following classes. o File and Writer o File out Output o File and Input o File and ScannerFile and Scanner63
3978073792When a program is finished using a file, it should do this. o Erase the file o Close the file o Throw an exception o Reset the read positionClose the file64
3978073793This class allows you to use the print and println methods to write data to a file. o File o FileReader o OutputFile o PrintWriterPrintWriter65
3978073794This class allows you to read a line from a file. o FileWriter o Scanner o InputFile o FileReaderScanner66
3978073795The while loop is a pretest loop. o True o FalseTrue67
3978073796The do-while loop is a pretest loop o True o FalseFalse68
3978073797The for loop is a posttest loop. o True o FalseFalse69
3978073798It is not necessary to initialize accumulator variables. o True o FalseFalse70
3978073799One limitation of the for loop is that only one variable may be initialized in the initialization expression. o True o FalseFalse71
3978073800A variable may be defined in the initialization expression of the for loop. o True o FalseTrue72
3978073801In a nested loop, the inner loop goes through all of its iterations for every iteration of the outer loop. o True o FalseTrue73
3978073802To calculate the total number of iterations of a nested loop, add the number of iterations of all the loops. o True o FalseFalse74
3978073803Characters serve specific purposes, such as marking the beginning or ending of a statement, or separating items in a list.Java Punctuation75
3978073804Rules that must be followed when writing a program. Syntax dictates how key words and operators may be used, and where punctuation symbols must appear.Syntax76
3978073805Named storage location in the computer's memory. (The most fundamental way that Java programs store an item of data in memory is with a variable.)Variables77
3978073806Generated by the Java CompilerByte code78
3978073807The data contained in an object. (An object is a software entity that contains data and procedures)Attributes79
3978073808A container for an applicationClass80
3978073809A group of one or more programming statements that collectively has a name eg: main method (file name!)Method81
3978073810Allows you to create one of two values: True or False (they can't be copied to a variable of any type other than Boolean)Boolean82
3978073811used to store characters. Can only hold 1 character at a timechar83
3978073812A set of numbers that are used as code for representing charactersUnicode84
3978073813consists of 8 bits... Integer that takes up 1 byte of memoryByte85
3978073814Integer that takes up 2 bytes of memoryShort86
3978073815Integer that takes up 8 bytes of memoryLong87
3978073816Whole numbers (uses 4 bytes of memory)Int88
3978073817Decimal number to the 15th place (uses 8 bytes of memory)Double89
3978073818Decimal number to the 7th place (uses 4 bytes of memory)Float90
3978073819Method used for reading strings, bytes, integers, long integers, short integers, floats, and doubles. It waits for the user to press the enter key before it returns a value.Scanner91
3978073820A collection of charactersString92
3978073821A value that is written in the code of a programLiteral93
3978073822a group of related classes JOptionPane, IS, ScannerPackages94
3978073823operator used that let you convert a value, even if it means that a narrowing conversion takes place (less accurate)Cast95
3978073824Allows you to format the appearance of floating-point numbers rounded to a specific number of decimal places. It is useful for formatting numbers that will be displayed in message dialogsDecimalFormat96
3978073825used in switch statements. Each case value must be unique. (Used as an alternative to if statements) Magic word - break multiple optionsCase97
3978073826Allows you to quickly display a dialog box, which is a small graphical window displaying a message or requesting input.JOptionPane98
3978073827% ... returns the remainder of a division operation involving two integers.Modulus99
3978073828Control structure that causes a statement or group of statements to repeat... has two important parts... 1) a Boolean expression that is tested for a true or false value, and 2) a statement or block of statements that is repeated as long as the expression is true. (pretest)While loop100
3978073829- Looks like an inverted while-loop... Always performs at least one iteration, even if the Boolean is false to begin with. (User has to answer yes for it to continue repeating) (posttest)Do-while loop101
3978073830ideal for performing a known number of iterations. Pre-test.For loop102
3978073831A loop that has no way of stopping. It continues to repeat until the program is interrupted.Infinite loop103
3978073832tests each expression before each iteration (while loop, for loop)Pre-test loop104
3978073833tests each expression after each iteration (Do-while loop)Post-test loop105
3978073834a special value that cannot be mistaken as a member of the list, and signals that there are no more values to be entered. When the user enters the sentinel value, the loop terminates.Sentinel106
3978073835variable used to accumulate the total of the numbers. (Running total)Accumulator107
3978073836constant (cant be changed)final108

Need Help?

We hope your visit has been a productive one. If you're having any problems, or would like to give some feedback, we'd love to hear from you.

For general help, questions, and suggestions, try our dedicated support forums.

If you need to contact the Course-Notes.Org web experience team, please use our contact form.

Need Notes?

While we strive to provide the most comprehensive notes for as many high school textbooks as possible, there are certainly going to be some that we miss. Drop us a note and let us know which textbooks you need. Be sure to include which edition of the textbook you are using! If we see enough demand, we'll do whatever we can to get those notes up on the site for you!