Programming
Dartmouth
Complete The Statement. The BASIC programming language was developed at _______________ College.
Single decimal printf statement example.
System.out.printf(" You know %d people.\n", totalPpl);
Which one of the following statements displays the output as (1.23e+02)?
System.out.printf("%(5.2e", -123.0);
Which one of the following statements displays the output as +00321.00?
System.out.printf("+%09.2f", 321.0);
Multiple format specifiers within a format string, example:
System.out.printf("Savings after %d years is: %f\n\n", years, total);
Most programming languages allow you to ask two or more questions in a single comparison.
True
Most languages allow you to use a variation of the decision structure called the ____ structure when you must nest a series of decisions about a single variable.
case
In a selection structure, you perform an action or task, and then you perform the next action in order.
False
____________ are diagrams used in mathematics and logic to help describe the truth of an entire expression based on the truth of its parts.
Truth tables
C
The ____ is used to represent output in a flowchart. a. square b. circle c. parallelogram d. triangle
hist
This is custom added to the .gitconfig file in the HOME directory. This is custom set. log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
The feature of programming languages that prevents assigning values of an incorrect data type
Type-safety
What is the name of the type that denotes floating-point numbers that can have fractional parts?
double
%h
hash code/HEX
A list of every variable name used in a program, along with its type, size, and description
Data dictionary
Diamond
Decision
In most programming languages, before you can use any variable, you must include a ____ for it.
Declaration
Methods in object-oriented programs use sequence, selection, and looping structures and make use of arrays. Answers True False
True
Most programming languages allow you to ask two or more questions in a single comparison. (T/F)
True
Program comments are a type of internal documentation.
True
Programmers can use either procedural programming or object-oriented programming to develop programs.
True
How many objects can be constructed from a given class?
as many as the computer's memory can store
What is the name of the = operator in Java?
assignment
assignment operator
assigns a value to a variable. An assignment operator is represented by an equal sign Java runs the program from the right side to the left side
Which one of the following operators computes the remainder of an integer division? a) / b) % c) \ d) !
b) %
GUI components are excellent examples of the best principles of object-oriented programming; they represent objects with attributes and methods that operate like ____.
black boxes
%b
boolean
Structured programming is sometimes called ____________________-less programming.
gotogo or togo-to
You should make sure that unavailable screen options are either dimmed (also called ____) or removed.
grayed
Which method call represents the invocation of a method that does not have arguments?
greeting.length()
____ are stored collections of classes that serve related purposes
liabaries
C#, C++, C, and Java use the symbol ____ as the logical OR operator.
ll
When a method exits, its ____ are removed. A. local variables B. comments C. classes D. instance variables
local variables
A ____ error results when you use a syntactically correct statement but use the wrong one for the current context.
logical
The repetition of a series of steps is called a(n) ____.
loop
Given a Graphics object, g, that is of width 500 and height 1000. Where would the point 500, 1000 be located?
lower-right
By convention among Java programmers, variables begin with a(n) _____________.
lowercase letter
The ____ is the standard terminal symbol for a flowchart.
lozenge
In an assignment statment, the part of the statement on the left-hand side of the equal sign is called what?
lvalue
After programs are put into production, making necessary changes is called ____.
maintenance
11. What contains sequences of instructions to perform a particular task?
method
Structured programs can be easily broken down into routines or ____ that can be assigned to any number of programmers.
modules
Using the event listener MouseMotionListener allows us to check for...
moved, dragged
With a(n) ____ program, a user can continue to click buttons while your program is reading a data file.
multithreaded
Which term describes a method of an object that modifies that object's internal data?
mutator
Placing a structure within another structure is called ____ structures.
nesting
The following pseudocode is an example of ____. if conditionA is true then do stepE else do stepB do stepC do stepD endif
nesting
27. Who/what is responsible for inspecting and testing the program to guard against logic errors?
programmer
The major difference between the two main programming styles in use today is the ____.
programmer's focus during the earliest planning stages of a project
Programs that use _____ code logic are unstructured programs that do not follow the rules of structured logic.
spaghetti
Attaching structures end to end is called ____ structures.
stacking
Another name for the parent class is:
super class
A ____ variable is not used for input or output, but instead is just a working variable that you use during a program's execution.
temporary
When creating a truth table, you must determine how many possible Boolean value combinations exist for the conditions. If there are two conditions, ____ combinations will exist.
three
What is the purpose of the assignment operator?
to change the value of a variable
Ctrl Spacebar can create methods
true
Using the event listener addKeyListener allows us to check for...
typed, released, pressed
Before a programmer plans the logic of the program, he or she must ____.
understand the problem
By convention among Java programmers, class names begin with a(n) _____________.
uppercase letter
%g
uses %e or %f whichever is shorter
A(n) ____ is a named memory location whose value can vary.
variable
In traditional programming, probably the most often used error-handling outcome was to ____.
terminate the program in which the offending statement occurred
30. A step sequence that eventually comes to an end is _____.
terminating
What is the output from the following print statements, assuming; String myString = "Testing"; Make sure all of your responses are in quotes, e.g. "Test". printf("%8s", myString);
" Testing" Strings shorter than the specified width will be printed with spaces, "Testing" requires 7 characters, 1 space is added as padding.
What is the output from the following print statements, assuming; String myString = "Testing"; Make sure all of your responses are in quotes, e.g. "Test". printf("%.4s", myString);
"Test" Strings longer than the specified precision will be truncated.
A format specifier always starts with the __ symbol
%
The format specifier ________ is a placeholder for an int value.
%d
20. What is the output of the following Java statement?
10
19. What is the output of the following Java statement?
4 + 6
AND
A binary Boolean operation that results in true only if both boolean values are true, otherwise the result is false
Which of the following guidelines will make code more explanatory for others?
Add comments to source code.
Which of the following values does not have a primitive type? A) 12.50 B) "Hello" C) 6 D) 1E4
B) "Hello"
Which of the following declares a variable that will store a measurement with fractional parts? A) int measure; B) double measure; C) String measure; D) integer measure;
B) double measure;
||
C#, C++, C, and Java use the symbol ____ as the logical OR operator.
To use a class in another package you need to ________ it. A) export B) overload C) rewrite D) import
D) import
Football Field
External Module Call
Arrow
Flowline (Direction of Program Flow)
What will be the value inside the variables a and b after the given set of assignments? int a = 20; int b = 10; a = (a + b) / 2; b = a; a++;
a = 16, b = 15
Convert each of the following decimal numbers into its equivalent binary number: a. 6 = b. 44 = c. 72 = d. 131 =
a. 6 = 110 b. 44 = 101100 c. 72 = 1001000 d. 131 = 10000011
You can invoke the println and print methods on which object?
any PrintStream object
When the variable starts with a lowercase letter and any subsequent word begins with an uppercase letter, this is called ____.
camel casing
What is the value inside the var variable at the end of the given code snippet? public static void main(String[] args) { int var = 30; var = var + 2 / var; var++; } a) 0 b) 1 c) 30 d) 31
d) 31
It makes sense that a parent class object has access to its child's data and methods.
false
Update: Fetch latest changes from origin
git fetch
Each object of a class has its own set of ___. A. methods B. instance variables C. constructors D. classes
instance variables
A method is a sequence of ___ that accesses the data of an object.
instructions
What is the name of the type that denotes whole numbers?
int
Which of the following is the best choice for a variable identifier that will store a name?
name
A(n) ____ is similar to a variable, except it can be assigned a value only once.
named constant
What series of println statements would produce the following output? This is a test of your knowledge of "quotes" used in 'string literals.' You're bound to "get it right" if you read the section on ''quotes.''
println statements to produce desired output: System.out.println("This is a test of your"); System.out.println("knowledge of \"quotes\" used"); System.out.println("in 'string literals.'"); System.out.println(); System.out.println("You're bound to \"get it right\""); System.out.println("if you read the section on"); System.out.println("''quotes.''");
The access specifier in the declaration of instance variables should be ___. A. class B. protected C. private D. public
private
git status -s or git status --short
short status (?? - new files that aren't tracked, A new files that have been added to the staging area. There are two columns to the output - the left hand column indicates that the file is staged and the right hand column indicates that it's modified.)
Attaching structures end-to-end
Staking structures
Which is not a method of the String class?
println
%e
scientific notation
%t
time and date
Boolean expressions are named after ____.
George Boole
git show v1.4
To see tag data
%s
string
18. What is the parameter in the given method call? System.out.println("Welcome");
"Welcome"
D
. In a flowchart, the ____ is used to represent processing. a. circle b. diamond c. triangle d. rectangle
What is the output of the following code snippet? System.out.printf("%5.3f", 20.0);
20.000
I want to find more information on the class hierarchy of Integer Class. How can I do this in the eclipse IDE?
At the top of the eclipse IDE menu bar-click NAVIGATE then click OPEN TO TYPE IN HIERARCHY (CTRL+SHIFT+H) then type Integer and you will get the hierarchical parents of class Integer.
Which statement declares a variable that will store an integer value? A) integer count; B) int count; C) count = 5; D) String count = 5;
B) int count;
Which one of the following statements displays the output as 54321.00?
System.out.printf("%8.2f", 54321.0);
Which package is automatically imported in any Java program? A) java.system B) java.lang C) java.language D) java.util
B) java.lang
Which of the following constructs a Circle of radius 3, assuming the construction parameter is the radius value? A) Circle(3).new B) new Circle(3) C) new.Circle(3) D) Circle(3)
B) new Circle(3)
Dotted Line with open rectangle
Comment/Explanation Some Declaring Explanation of code
What is the output of the following code: int num1 = 6; int num2 = 10; num1 = num1 + num2; num2 = num1 + num2; System.out.println(num1 + ", " + num2); A) 6, 10 B) 16, 16 C) 16, 22 D) 16, 26
D) 16, 26
What does API stand for? A) Applet Programming Interface B) Application Programmer Interaction C) Application Programming Instance D) Application Programming Interface
D) Application Programming Interface
"System.out" is an instance of (example of?) which class? A) String B) Println C) System D) PrintStream
D) PrintStream
git fetch
Fetches all the objects from the remote repository that are not present in the local one. Example: git fetch origin
git pull
Fetches the files from the remote repository and merges it with your local one. This command is equal to the git fetch and the git merge sequence. Example: git pull origin
Boolean expressions are named after _______.
George Boole
____ variables and constants are known to the entire program.
Global
gitk
Graphical Tcl/Tk based interface to a local Git repository.
Equipment, or the physical devices, associated with a computer
Hardware
B
If you use an otherwise correct word that does not make sense in the current context, programmers say you have committed a ____ error. a. syntax b. logic c. semantic d. programming
git remote show [remote-name]
If you want to see more information about a particular remote
git log --stat
If you want to see some abbreviated stats for each commit, you can use the this option
.gitignore
Ignoring files
True and False False and True False and False
In a truth table, the expression ____ is false.
_______ is the concept that other classes should not alter an object's attributes-only the methods of an object's own class should have that privilege.
Information hiding
When using ________, you can develop new classes more quickly by extending existing classes that already work.
Inheritance
______ is the process of acquiring the traits of one's predecessors
Inheritance
%d
Integer values
Why is it a good idea for a programmer to write comments about a method first, before implementing it? A. It can help to assign good variable names. B. It is a good idea for complex methods, but not simple ones. C. It is an excellent test to ensure that the programmer firmly understands what is needed. D. Without comments it is not possible to compile the code.
It is an excellent test to ensure that the programmer firmly understands what is needed.
Which Is correct:
It is incorrect to initialize a string variable with a number
Located in the top of the eclipse menu bar open a customized perspective - if you click on _____ and then click ______ and ________ perspective
Located in the top of the eclipse menu bar open a customized perspective - if you click on WINDOW and PERSPECTIVE and CUSTOMIZED perspective
Create a new XML file
Located on the top of the eclipse IDE - Click FILE - NEW - OTHER - XML
J
Match The Term With the Def. a. volatile memory b. software c. syntax error d. machine e. sentinel f. pseudocode. g. hardware h. flowchart language i. flowlines j. documentation All the supporting paperwork for a program
A
Match The Term With the Def. a. volatile memory b. software c. syntax error d. machine e. sentinel f. pseudocode. g. hardware h. flowchart language i. flowlines j. documentation Contents are lost when the computer is turned off or loses power
In class diagrams, a ________ sign precedes the items that are private.
Minus
Often can be used in multiple programs
Modules
How can you view all of your tasks that you need to complete in your source code?
On the top of the eclipse IDE menu bar - Click - WINDOWS- SHOW VIEW - TASKS. you will be shown a LIST of TASKS at the end of the eclipse IDE. Click on each line to take you to the particular task.
F
Once a program is completely coded, it is ready for a company or organization to use.
Operator Precedence
PEMDAS then Relational then Logical then Assignment
Hexagon
Pre-processing/formatting
how can you add a bookmark to a line in your source code
Press your Java source code editor - In the MARKER BAR (line numbers on the left-hand side of code) RIGHT-CLICK and press ADD BOOKMARK
What's the quickest way to search for a literal or character pattern anywhere in your workspace files
Pressing Ctrl + H or on the top of the eclipse IDE menu bar-click SEARCH - SEARCH or FILE or JAVA
An added statement that gets the first input value in a program
Priming read
"System.out" is an example of which class?
PrintStream
English-like representation of the logical steps it takes to solve a problem
Pseudocode
git push
Pushes all the modified local objects to the remote repository and advances its branches. Example: git push origin master
Insider Java source code - a variable or method is underlined in red - highlighting an error - how can you quick fix this error?
QUICK FIX CTRL+1 - highlights the list of solutions
You can perform a _______ by making comparisons using either the lowest or highest value in a range of values.
Range check
A file can be open using 3 different modes. Explain each of them and their behavior when the file being open already exist and when athe file being open does not exist.
Read, Write, and Append.
A class diagram consists of a ______ divided into three sections.
Rectangle
The following program is legal under Java's syntax rules, but it is difficult to read because of its layout and lack of comments. Reformat it using the rules given in Chapter 1, and add a comment header at the top of the program. (Practice-It isn't really able to check that you satisfied the requirements of this question. You will receive credit as long as you supply a reasonable amount of indentation and add two lines of // comments.) public class Messy{public static void main(String[]args){message () ;System.out.println() ; message ( );} public static void message() { System.out.println( "I really wish that" );System.out.println ("I had formatted my source") ;System.out.println("code correctly!");}}
Reformatted version of Messy program: // Suzy Student, Fall 2048 // This program prints a cautionary message about messy formatting // of Java programs. public class Messy { public static void main(String[] args) { message(); System.out.println(); message(); } public static void message() { System.out.println("I really wish that"); System.out.println("I had formatted my source"); System.out.println("code correctly!"); } }
The feature of programs that assures you a module has been tested and proven to function correctly
Reliability
Logically snarled program statements
Spaghetti code
subspecifier: .precision:
Specifies the number of digits to print following the decimal point. If the precision is not specified a default precision of 6 is used.
What series of println statements would produce the following output? "Several slashes are sometimes seen," said Sally. "I've said so." See? \ / \\ // \\\ ///
System.out.println("\"Several slashes are sometimes seen,\""); System.out.println("said Sally. \"I've said so.\" See?"); System.out.println("\\ / \\\\ // \\\\\\ ///");
Racetrack
Terminal (Start Stop)
The _____ _____ allows users to place break points in the java code. To set a break point, in the __________ area _____ _____ on the __________ bar and select Toggle Breakpoint.
The JAVA EDITOR allows users to place break points in the java code. To set a break point, in the EDITOR area RIGHT-CLICK on the MARKER bar and select Toggle Breakpoint.
How can you view the Java builder of a project?
The Java builder can be viewed by RIGHT CLICKING the project in the PROJECTS FOLDER - PROPERTIES. The projects folder is located on the left-hand side of the Eclipse IDE.
git rm
The command removes the file from your tracked files and from your hard disk.
Assuming the following Java statement: int num = 10; What does the variable num store?
The numeric value 10.
How must each format specifier argument be separated within the parenthesis?
These arguments are additional input to the printf() method, with each argument separated by a comma within the parentheses.
git add
These commands specify the files you want to track (tracking new files).
To open a new perspective, in the top of the eclipse IDE menu bar- click on the ______menu and select ____ ______ > Other
To open a new perspective, click on the WINDOWS menu and select PERSPECTIVE -> OPEN PERSPECTIVE you have a choice of Java perspective-debug perspective etc.
git diff --cached or git diff --staged
To see what you've staged so far
B
Typically, a programmer develops a program's logic, writes the code, and ____ the program, receiving a list of syntax errors. a. runs b. compiles c. executes d. tests
git log -p -2
You can also use this option, which limits the output to only the last two entries
Range Check
You can perform a ____ by making comparisons using either the lowest or highest value in a range of values.
Which of the following statements is true about constructors? Providing a constructor for a class is optional. You can only provide one constructor for a class. The body of the constructor must initialize all instance variables or the constructor will not successfully compile. A constructor has a void return type.
a) Providing a constructor for a class is optional.
Which of the following statements about classes is correct? a) By convention, class names begin with a lowercase letter. b) A class declares the methods that you can apply to its objects. c) All entities, even primitive numbers, are classes. d) A class is a sequence of instructions that accesses the data of an object.
b) A class declares the methods that you can apply to its objects.
Which statement declares a variable that references a Circle of radius 3? a) Circle c = Circle(3) b) Circle c = new Circle(3); c) Circle c.new.Circle(3); d) c.Circle(3);
b) Circle c = new Circle(3);
When are instance variables initialized? a) Instance variables are initialized when the method is called. b) Instance variables are initialized with a default value before a constructor is invoked. c) You must initialize instance variables in the constructor. d) You must initialize instance variables in a method body.
b) Instance variables are initialized with a default value before a constructor is invoked.
What is wrong with the following code snippet? public class Area { public static void main(String[] args) { int width = 10; height = 20.00; System.out.println(''area = '' + (width * height)); } } a) The code snippet uses an uninitialized variable. b) The code snippet uses an undeclared variable. c) The code snippet attempts to assign a decimal value to an integer variable. d) The code snippet attempts to add a number to a string variable.
b) The code snippet uses an undeclared variable.
What happens to the fractional part when a division is performed on two integer variables? a) The fractional part is rounded off to the nearest integer value. b) The fractional part is discarded. c) Two integers cannot be used in division; at least one of the operands should be a floating-point number. d) Instead of using an integer division, you should use the modulus operator to perform floating-point division.
b) The fractional part is discarded.
The name of the constructor is always the same as the name of the __. a) access specifier b) class c) instance variable d) parameter variable
b) class
Create: From existing data
cd ~/projects/myproject git init git add
What is the result of the following code snippet? public static void main(String[] args { double circleRadius; double circleVolume = 22 / 7 * circleRadius * circleRadius; System.out.println(circleVolume); }
compile-time error
8. What translates high-level descriptions into machine code?
compiler
What tool translates high-level instructions into low level machine code?
compiler
A ____ is a copy that is kept in case values need to be restored to their original state. Answers: a. read-only file b. secondary file c. primary file d. backup file
d. backup file
A ____ is a set of program statements that lists the characteristics of each object and the methods each object can use. Answers: a. class model b. class interface c. class reference d. class definition
d. class definition
%f
decimal FLOATING POINT
Object-oriented programs employ a more specific group of techniques for handling errors called ____.
exception handling
In the code below, write a statement that sets the graphic to green. public class ItalianFlagComponent extends JComponent { public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; . . . ____ . . . } }
g2.setColor(Color.GREEN);
Show: All local branches
git branch
When a program has several modules calling other modules, programmers often use a program ____, which operates similarly to an organizational chart, to show the overall picture of how modules are related to one another.
hierarchy chart
What term is used to refer to languages that allow programmers to describe tasks at a higher conceptual level than machine code?
high-level
git log
history
The priming read is an example of a(n) ____ task.
housekeeping
Which term is used to describe the name of a variable, method, or class?
identifier
git mv file_from file_to
if you want to rename a file in Git, you can run something like
%n
inserts newline character
What are the values of num1 and num2 after this snippet executes? double num1 = 4.20; double num2 = num1 * 10 + 5.0;
num1 = 4.20 and num2 = 47.0
A specific numeric value is often called a(n) ____.
numeric constant
In some programming languages, such as C#, Visual Basic, and Java, every class you create is a child of one ultimate base class, often called the ____ class
object
A(n) ____ is a list of the objects used in a program, including which screens they are used on and whether any code is associated with them.
object dictionary
Which of the following terms denotes the memory location of an object?
object reference
What do object variables store?
object references
Using ____ involves writing down all the steps you will use in a program.
pseudocode
Which line of code is part of the public implementation of the BankAccount class? A. balance = balance - amount; B. public BankAccount(double initialBalance) C. balance = balance + amount; D. return balance;
public BankAccount(double initialBalance)
A(n) ____ in a class diagram indicates public access
public access
In Java, a comment on a line begins with which characters?
//
What is the output from the following print statements, assuming: float myFloat = 45.1342f; System.out.printf("%09.3f", myFloat);
00045.134 ; There are total of 9 characters printed: 5 digits before the decimal point, the decimal point, and 3 digits after the decimal point.
The formatting sub-specifiers are included between the % and format specifier characters. Explain:
The formatting sub-specifiers are included between the % and format specifier characters. For example, printf("%.1f", myFloat); causes the floating-point variable, myFloat, to be output with only 1 digit after the decimal point; if myFloat was 12.34, the output would be 12.3. Format specifiers and sub-specifiers use the following form:
T
The heart of the programming process lies in planning the program's logic.
The java builder is responsible for __________ the java source code and __________classes.
The java builder is responsible for COMPILING the java source code and GENERATING classes.
git status
The main tool you use to determine which files are in which state (checking the status of your files).
The setVisible method of the JFrame class returns what kind of argument?
The setVisible method does not return a result.
What is the short key to run and debug mode?
The shortcut key to launch the previously launched Java application in the debug mode is F11.
A _______ reference is an automatically created variable that holds the address of an object and passes it to an instance method whenever the method is called
This
How to enable automatic compilation of a Java application?
To enable automatic compilation of Java - on the top of the eclipse IDE menu bar - click PROJECT and then click BUILD AUTOMATICALLY
To reopen a closed project in the ________ __________ view select the ________ project and click on the _______menu and select Open Project.
To reopen a closed project on the left - hand side of the eclipse IDE - in the PACKAGE EXPLORER view select the CLOSED project and click on the PROJECT menu and select Open Project.
Structured programming is sometimes called goto-less programming.
True
With object-oriented programming, once you create an object, you can develop new objects that possess all the traits of the original object, plus any new traits you desire.
True
With will-written methods that belong to classes you use, you need not understand how they work internally to be able to use them. Will be like if any objects are even
True
Within any object-oriented program, you continuously make requests to an object's methods, often including arguments as part of those requests. Answers: True False
True
You can use multiple windows in eclipse IDE. True or false?
True: Each window can have a DIFFERENT PERSPECTIVE open in them. For example you could open two Eclipse windows one in the JAVA PERSPECTIVE and the other in the DEBUG PERSPECTIVE.
Integer Modulus
A division process that results in a whole number answer representing the remainder of the division process, discarding the actual answer. Indicated by the % sign.
Integer Division
A division process that results in a whole number answer, discarding or truncating any fractional remainder.
F
A flowchart is an English-like representation of the logical steps necessary to solve a problem.
A list of __________ allows one to view the values of selected variables and expressions.
A list of WATCHES allows one to view the values of selected variables and expressions.
Which of the following statements about methods is correct?
A method is a sequence of instructions that could access the data of an object
Assuming the following Java statement: Circle c1 = new Circle(3); What does the variable c1 store?
A reference to the constructed Circle object.
B
A(n) ___ is a named memory location whose value can vary. a. input b. variable c. output d. logic
D
A(n) ____ is a software package that provides an editor, a compiler, and other programming tools. a. GUI b. CGI c. GDE d. IDE
C
A(n) ____ tells the user what to enter. a. command line b. input screen c. prompt d. data line
What is the output of the following code: Circle c1 = new Circle(3); Circle c2 = new Circle(3); c1.setRadius(4); System.out.println(c2.getRadius()); A) 3 B) 8 C) 6 D) 4
A) 3
What is the output of the following code: Circle c1 = new Circle(3); Circle c2 = c1; c1.setRadius(4); System.out.println(c2.getRadius()); A) 4 B) 3 C) 6 D) 8
A) 4
A(n) _______ is the adjective that defines the type of access that outside classes will have to the attribute or method.
Access specifier
Binary Operator
An arithmetic operator that needs two input elements to work
An eclipse _______is the name given to an initial collection and arrangement of views and an editor area.
An eclipse PERSPECTIVE is the name given to an initial collection and arrangement of views and an editor area. On the top RIGHT-HAND corner of eclipse you can change to JAVA PERSPECTIVE or DEBUG PERSPECTIVE or JAVA BROWSING PERSPECTIVE etc
T
An infinite loop is a flow of program logic that repeats and never ends.
Unary Operator
An operator in mathematics or in logic which works on only one operand, such as the negative, positive, or complement operators.
Overloaded Operator
An operator that can perform more than one function (ex. + for addition and for string concatenation).
In a flowchart, an ____ is most often represented by a three-sided box that is connected to the step it references by a dashed line.
Annotation symbol
What does API stand for?
Application Programming Interface
Class diagrams are a type of _____ diagram.
Unified Modeling Language
git cat-file
Used to view the type of an object through the SHA-1 value. Example: git cat-file -t e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 blob
D
Using ____ involves writing down all the steps you will use in a program. a. a compiler b. an interpreter c. a flowchart d. pseudocode
Data type
Both operands in a comparison expression must be the same ____.
A series of nested if statements is also called a _________ if statement.
Cascading
Most languages allow you to use a variation of the decision structure called the ___ structure when you must nest a series of decisions about a single variable.
Case
Named memory locations whose contents can vary or differ over time
Variables
Named memory locations whose contents can vary or differ over time.
Variables
b
What (if any) type of error occurs with the following code if the user input is ABC? public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter a number: "); String str = in.next(); int count = Integer.parseInt(str); System.out.println("Input is " + count); } a) Compile-time error b) Run-time error c) Overflow error d) Illegal expression
a
What does the following statement sequence print? String str = "Hello"; int n = str.length(); String mystery = str.substring(0, 1) + str.substring(n - 2, n + 1); System.out.println(mystery); a) Run-time error b) He c) Ho d) Hry
a
What does the following statement sequence print? String str = "Java"; str += " is powerful"; System.out.println(str); a) Java is powerful b) Java + is powerful c) is powerful d) Compile-time error
d
What does the following statement sequence print? final String str = "Java"; str += " is powerful"; System.out.println(str); a) Java is powerful b) Java + is powerful c) is powerful d) Nothing; compile-time error
d
What is the output of the following code snippet? System.out.printf("%5.3f", 20.0); a) 20 b) 20.0 c) 20.00 d) 20.000
c
What is the output of the following code snippet? int counter = 0; counter++; System.out.print("The initial value of the counter is "); System.out.println(count); a) The initial value of the counter is 0 b) The initial value of the counter is 1 c) The code will not compile d) The initial value of the counter is
36
What is the output of the following code snippet? public static void main(String[] args) { int s; double f = 365.25; s = f / 10; System.out.println(s); }
a (how???)
What is the output of the following code snippet? public static void main(String[] args) { int num1 = 10; int num2 = 5; int num3 = 200; num3 = num3 % (num1 * num2); System.out.println(num3); } a) 0 b) 4 c) 10 d) 250
What keyword is used when one class wants to inherit from another class?
extends
A GUI picture album has a picture or sketch of a screen the user will see when running a program
false
OR
false only when both are false
When you use a menu bar, it is at the top of the screen in most GUI programs, and the first menu item is almost always ____.
file
Which one of the following statements defines a constant with the value 123?
final int MY_CONST = 123;
forget
forget
%s, %f, and %d, located in the format string of a printf statement, are called ______
format specifiers
Based on the following code, which of the following statements sets the frame to a width of 400 and a height of 200: final int FRAME_WIDTH = 400; final int FRAME_HEIGHT = 200; JFrame frame = new JFrame();
frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
Based on the following statement, which of the following statements sets the title of the frame: JFrame frame = new JFrame();
frame.setTitle("An Empty Frame");
A variable's unknown value is commonly called ____.
garbage
Create: From existing repo
git clone ~/existing/repo ~new/repo git clone git://host.org/project.git git clone ssh://[email protected]/proj.git
Publish: Commit all your local changes
git commia -a
Search working directory for foo()
git grep "foo()"
Show: History of changes
git log
Show: History of changes for file with diffs
git log -p $file $file $dir/ec/tory/
Update: Pull latest changes from origin
git pull
Publish: Push changes to origin
git push
Revert: Return to the last committed state
git reset --hard
Revert: Revert specific commit
git revert $id
Show: Files changes in working directory
git status
Publish: Mark a version / milestone
git tag V1.0
In older languages, you could leave a selection or loop before it was complete by using a ____ statement.
go to
Some people call the selection structure a(n) ____________________ statement.
if-then-elseif then else
Encapsulation allows a programmer to use a class without having to know its ____. A. interface B. implementation C. methods D. name
implementation
To use a class in another package you need to ________ it.
import
Which import statement allows for the use of the Rectangle class?
import java.awt.Rectangle;
relational operators
in Java help check a condition in an expression in the Java program Greater Than > Less Than < Greater Than or Equal To >= Less Than or Equal To <= Equal To == Not Equal To !=
As programs become larger and more complicated, the need for good planning and design ____ .
increases
A(n) ____ is a repeating flow of logic with no end.
infinite loop
Declaring a starting value for a variable is known as ____ the variable.
initializing
Which of the following code fragments will cause an error?
int luckyNumber; System.out.println(luckyNumber);
Which of the following statements places input into the variable value given this line of code? Scanner in = new Scanner(System.in);
int value = in.nextInt();
%h
int, char, long, short; Prints a hexadecimal integer value.
%d
int, long, short; Prints a decimal integer value.
%o
int, long, short; Prints an octal integer value.
What is wrong with the following code? int count = 2000 * 3000 * 4000;
integer overflow
The public constructors and methods of a class form the public _____ of the class. A. initialization B. encapsulation C. implementation D. interface
interface
A derived class always ____ case or instance of the more general base class.
is a
The second approach
is cloning an Existing Repository
The first approach
is initializing a Repository in an Existing Directory (git init)
lightweight tag
is very much like a branch that doesn't change - it's just a pointer to a specific commit
You may hear programmers refer to looping as ____.
iteration
Which package is automatically imported in any Java program?
java.lang
When using the Timer object we want to import which library
javax.swing.Timer
Which operator constructs object instances?
new
Install the eclipse Optimizer plug-in
on the top of the eclipse IDE menu bar - Click - HELP - ECLIPSE MARKETPLACE then click the SEARCH tab and search for "eclipse Optimizer". Then install and restart eclipse
The maximum number of entry points that any programming structure can have is ____.
one
By using ____, you can use reasonable, easy-to-remember names for methods and concentrate on their purpose rather than on memorizing different method names.
polymorphism
Using the event listener MouseListener allows us to check for... (check all that apply)
pressed, clicked, entered, exited, released
A ____ read is an added statement that gets the first input value in a program.
priming
subspecifier: flags: example:
printf("%+f", myFloat); +12.340000 printf("%08.2f", myFloat); 00012.34
Runtime errors
program runs but gets an exception error message • Program may be terminated
Logic errors:
program runs but results are not correct
What is the term used to specify the collection of things you can do with objects that belong to a class?
public interface
Which of the following represents a method declaration with a void return type?
public void setValue(int value) { ... }
Which of the following method headers uses the correct syntax? public static example void[] { public void static example() { public void static example{} ( public static void example() { public static example() {
public void static example() {
With most OOP languages, you must ____ components, or sign them up so that they can react to events initiated by other components.
register
Code that has already been tested and used in a variety of situations is said to be ____.
reliable
Which method could you use to obtain the string "1234567890" from the string "123-456-7890"?
replace
&& operator
represents the logical operation AND in Java expression shows the result true if both its operands have the same value and false if not 1 represents true, 0 represents false
! operator
represents the logical operation NOT this type of operator the result is the opposite of the first operand
|| operator
represents the logical operation OR in Java expression shows the result false only if both its operands have the same value, and true even if one value is satisfied
The value calculated by a method is called its _____ value.
return
The ____ dictate the order in which operations in the same statement are carried out.
rules of precedence
The case structure is a variation of the ____ structure.
selection
Programmers refer to programs that contain meaningful names as ____.
self-documenting
With a(n) ____, you perform an action or task, and then you perform the next action, in order.
sequence structure
A structured program includes only combinations of the three basic structures: ____.
sequence, selection, and loop
One way to straighten out an unstructured flowchart segment is to use the ____ method.
spaghetti bowl
The following pseudocode is an example of ____. do stepA do stepB if conditionC is true then do stepD else do stepE endif while conditionF is true do stepG endwhile
stacking
14. What term is used to refer to a sequence of characters enclosed in quotation marks?
string
Usually, ____ variables are not considered to be equal unless they are identical.
string
26. What is the term used to describe an error detected by the compiler that is a violation of the programming language rules?
syntax error
A(n) ____ is a program that you use to create simple text files.
text editor
The advantage in marking a class as "abstract" is that... (check all that apply)
the class can force child classes to implement methods and it prevents the creating objects of the class
A short-circuit evaluation is where each part of an expression is evaluated only as far as necessary to determine whether the entire expression is true or false.
true
In a truth table, the expression _____ is true.
true AND true
XOR
true only when both are opposite
AND
true only when both are true
A constructor that accepts all properties is known by me as a ______________________ constructor
workhorse
What will be the value inside the variables x and y after the given set of assignments? int x = 20; int y = 10; x = (x - y) * 2; y = x / 2;
x = 20, y = 10
C#, C++, and Java use the symbol ______ as the logical OR operator.
||
A variation of the selection structure
Case structure
Which statement calls a constructor with no construction arguments?
Circle c = new Circle();
Procedural
Complete The Statement. A(n) ____________________ programmer would approach a problem by dividing the process into manageable subtasks.
Beginners All Purpose Symbolic Instruction Code
Complete The Statement. BASIC stands for B_____________ A___-___________ S___________ I___________ C_______.
Circle
Continuation on another page
git archive
Creates a tar or zip file including the contents of a single tree from your repository. Example: git archive --format=zip master^ README >file.zip
git tag -a v1.4 -m 'my version 1.4'
Creating an annotated tag in Git is simple.
Which import statement allows for the use of the Rectangle class? A) import java.geom.Rectangle2D; B) import java.geom.Rectangle; C) import java.geom.RectangularShape; D) import java.awt.Rectangle;
D) import java.awt.Rectangle;
Which of the following declares a variable that will store a count with an integer value? A) integer count; B) double count; C) String count; D) int count;
D) int count;
Which is not a method of the String class? A) length B) toUpperCase C) toLowerCase D) println
D) println
The output of a method is called its __________ value. A) implicit B) explicit C) parameter D) return
D) return
What is the purpose of the assignment operator? A) to check for inequality B) to check for identity C) to check for equality D) to change the value of a variable
D) to change the value of a variable
With this, you ask a question, and, depending on the answer, you take one of two courses of action structure
Decision
A statement that provides a data type and an identifier for a variable
Declaration
f) Replace lines 3-4 with: System.out.println("The first rule of Java Club is,");
Different program output: The output would now have no line break between "The first rule" and "of Java Club is," in its output.
All the supporting paperwork for a program
Documentation
git fsck
Does an integrity check of the Git file system, identifying corrupted objects. Example: git fsck
What is the result of the following code snippet? double bottles; double bottleVolume = bottles * 2; System.out.println(bottleVolume);
Does not compile
git gc
Garbage collector for your repository. Optimizes your repository. Should be run occasionally. Example: git gc Counting objects: 7, done. Delta compression using up to 2 threads. Compressing objects: 100% (5/5), done. Writing objects: 100% (7/7), done. Total 7 (delta 1), reused 0 (delta 0)
How can you get more information quickly on various aspects of your code?
HOVER HELP-HOVERING the MOUSE over various code terms you can get FURTHER INFORMATION in regards to the JAVADOC description of the method or variable etc.
The relationship created when using a class object within another class object is also called a(n) ____ relationship
Has-a
___________________ tasks include any steps you must perform at the beginning of a program to get ready for the rest of the program.
Housekeeping
What does the following statement sequence print? String str = "Harry"; int n = str.length(); String mystery = str.substring(0, 1) + str.substring(n - 2, n); System.out.println(mystery);
Hry
True and True
In a truth table, the expression ____ is true.
git log -<n>
In fact, you can do this, where n is any integer to show the last n commits.
git rm --cached README
In other words, you may want to keep the file on your hard drive but not have Git track it anymore
Programmers say that variables and constants declared within a module are
In scope
You want to remind yourself to change a piece of code in a certain line. How can you do this in eclipse IDE
Inside your Java source code editor- on the left-hand side click on the MARKER BAR then right-click ADD TASK then type in the DESCRIPTION what you wish to CHANGE on this particular line of code.
A(n) ____ method operates appropriately for such separate instance of a class.
Instance
Notecard
Internal Module Call
git branch
Lists existing branches, including remote branches if '-a' is provided. Creates a new branch if a branch name is provided. Example: git branch -a * master remotes/origin/master
Create a new Java class in a Java project
Located in the top of the eclipse IDE- Click FILE - NEW - CLASS
Located on the bottom of the eclipse IDE Eclipse views allow users to see a _______representation of project _______.
Located on the bottom of the eclipse IDE Eclipse views Eclipse views allow users to see a GRAPHICAL representation of project METADATA.
Located on the top right-hand corner of the eclipse IDE is an eclipse ________. This is the name given to an initial collection and arrangement of views and an editor area.
Located on the top right-hand corner of the eclipse IDE is an eclipse PERSPECTIVE. This is the name given to an initial collection and arrangement of views and an editor area e.g. Java Perspective-Debug Perspective-Java Browsing etc.
Continue to repeat actions while a condition remains true
Loop structure
Represent(s) the millions of on off circuits within the computer
Machine language
git clone
Makes a Git repository copy from a remote source. Also adds the original location as a remote so you can fetch from it again and push to it if you have permissions. Example: git clone [email protected]:user/test.git
F
Match The Term With the Def. a. volatile memory b. software c. syntax error d. machine e. sentinel f. pseudocode. g. hardware h. flowchart language i. flowlines j. documentation English-like representation of the logical steps it takes to solve a problem
G
Match The Term With the Def. a. volatile memory b. software c. syntax error d. machine e. sentinel f. pseudocode. g. hardware h. flowchart language i. flowlines j. documentation Equipment, or the physical devices, associated with a computer
C
Match The Term With the Def. a. volatile memory b. software c. syntax error d. machine e. sentinel f. pseudocode. g. hardware h. flowchart language i. flowlines j. documentation Incorrectly spelled words, or reversing the proper order of two words in a computer program
git merge
Merges one or more branches into your current branch and automatically creates a new commit if there are no conflicts. Example: git merge newbranchversion
The following program contains four errors. Correct the errors and submit a working version of the program. public class FamousSpeech public static void main(String[]) { System.out.println("Four score and seven years ago,"); System.out.println("our fathers brought forth on"); System.out.println("this continent a new nation"); System.out.println("conceived in liberty,"); System.out.println("and dedicated to the proposition"); System.out.println("that"); /* this part should System.out.println("all"); really say, System.out.println("men"); "all PEOPLE!" /* System.out.println("are"; System.out.println("created"); System.out.println("equal"); } }
Mistakes in FamousSpeech program: line 1: A { brace is missing. line 2: The word args is missing. line 8: The comment on lines 8-10 accidentally comments out lines 9-10 of the program. Using // comments would fix the problem. line 11: A closing right parenthesis ) is missing.
What is the output produced from the following statements? - System.out.println("\"Quotes\""); - System.out.println("Slashes \\//"); - System.out.println("How '\"confounding' \"\\\" it is!");
Output of statements: "Quotes" Slashes \// How '"confounding' "\" it is!
What is the output produced from the following statements? - System.out.println("Shaq is 7'1"); - System.out.println("The string \"\" is an empty message."); - System.out.println("\\'\"\"");
Output of statements: Shaq is 7'1 The string "" is an empty message. \'""
What is the output produced from the following statements? (Treat tabs as aligning to every multiple of eight spaces.) - System.out.println("name\tage\theight"); - System.out.println("Archie\t17\t5'9\""); - System.out.println("Betty\t17\t5'6\""); - System.out.println("Jughead\t16\t6'");
Output of statements: name age height Archie 17 5'9" Betty 17 5'6" Jughead 16 6'
You can use ______ for clarity and to override the default order of operations.
Parentheses
When the first letter of a variable name is uppercase, as in HourlyWage, the format is known as ____ casing.
Pascal casing
%%
Prints the '%' character.
%n
Prints the platform-specific new-line character.
Object-oriented programmers usually specify that their data fields will have _______ access.
Private
Rectangle
Process/Processing
____ data items may involve organizing or sorting them, checking them for accuracy, or performing calculations with them.
Processing
F
Professional computer programmers write programs to satisfy their own needs.
Instructions that tell the computer what to do
Software
F
Software can be classified into two broad types: application software and programming software.
subspecifier: width;
Specifies the minimum number of characters to be printed. If the formatted value has more characters than the width, it will not be truncated. If the formatted value has fewer characters than the width, the output will be padded with spaces (or 0's if the '0' flag is specified).
The set of all the values or contents of a class object's instance variables is also known as its ______
State
If you had a class called MyClass, which of the following could MyClass inherit?
String
Usually, ____ variables are not considered to be equal unless they are identical.
String
Usually, _________ variables are not considered to be equal unless they are identical.
String
What is the nickname for the graphical user interface library in Java?
Swing
Which of the following statements displays price = 20.00
System.out.print("price = "); System.out.printf("%10.2f", price);
Which of the given System.out.print statements generates the following output? ABCDE"\
System.out.println("ABCDE\"\\");
Which of the following represents a method call to a method with a void return type?
System.out.println()
If-Then
The ____ clause is the part of the decision that holds the action or actions that execute when the tested condition in the decision is true.
B
The ____ is the standard terminal symbol for a flowchart. a. circle b. lozenge c. diamond d. square
What is the output of the following code snippet? int counter = 0; counter++; System.out.print("The initial value of the counter is "); System.out.println(count);
The code will not compile
&&
The conditional AND operator in Java, C++, and C# is ____.
Equality Operator
==, !=
The ____ sign means "greater than."
>
The _____ sign means "greater than"
>
What is an object?
An entity in your program that is manipulated by calling methods.
Assuming the following Java statement: Circle c1 = new Circle(3); What does the variable c1 store? A) The constructed object itself. B) A reference to the Circle class. C) A reference to the memory location of the constructed object. D) The numeric value 3.
C) A reference to the memory location of the constructed object.
What is an object? A) A sequence of instructions. B) Any value stored in a variable. C) An entity in your program that is manipulated by calling methods. D) Any input to a method.
C) An entity in your program that is manipulated by calling methods.
Which class is part of the java.lang package? A) Rectangle B) PrintStream C) String D) Circle
C) String
If greeting refers to a String object, which of the following is a syntactically correct Java statement? A) System.out.println(length().greeting); B) System.out.println(greeting()); C) System.out.println(greeting.length()); D) greeting.println("Hello");
C) System.out.println(greeting.length());
What do object variables store? A) objects B) classes C) references D) numbers
C) references
3.
Click on Run and then try the debug commands to see what they do and see how the values of the variables change in the Variable window and what the outputs are in the Console window.
Which statement about identifiers is correct? A) Identifiers are not case sensitive. B) Spaces are permitted inside identifiers. C) Identifiers can use symbols such as ? or %. D) Identifiers can be made up of letters, digits, and the underscore (_) character.
D) Identifiers can be made up of letters, digits, and the underscore (_) character.
What is the name of the type that denotes a string of characters? A) Characters B) char C) charString D) String
D) String
Which of the following method calls illustrates the return value of a method as a parameter? A) greeting.length(); B) greeting.println("Hello"); C) System.out.println(length.greeting()); D) System.out.println(greeting.length());
D) System.out.println(greeting.length());
Assuming the following Java statement: int num = 10; What does the variable num store? A) A reference to the memory location where the value 10 is stored. B) A reference to the int primitive type. C) An object representing the number 10. D) The numeric value 10.
D) The numeric value 10.
If greeting is a String object, which method call is incorrect? A) greeting.length() B) greeting.toLowerCase() C) greeting.toUpperCase() D) greeting.println()
D) greeting.println()
Which of the following terms denotes the memory location of an object? A) implicit parameter B) mutator method C) encapsulation D) object reference
D) object reference
The case structure is a variation of the sequence structure and the do loop is a variation of the while loop.
False
The keyboard and printer are the default input and output devices. Answers: True False
False
Variable names can be more than one word with blanks between the words.
False
Object attributes are often called _______ to help distinguish them from other variables you might use.
Fields
Pictorial representation of the logical steps it takes to solve a problem
Flowchart
For each format specifier within the format string, explain what must be provided?
For each format specifier within the format string, the value to be printed must be provided in the printf() statement as arguments following the format strings.
First ask the question that is more likely to be false
For maximum efficiency, a good rule of thumb in an AND decision is to ____.
First ask the question that is more likely to be true
For maximum efficiency, a good rule of thumb in an OR decision is to ____.
How to open design view in WIndowBuilder in Eclipse?
On the bottom on the eclipse IDE click DESIGN Tab - Make sure the source code is a JFrame code
Export a project to a jar file.
On the left-hand side of the eclipse IDE- In the PROJECT EXPLORER folder - Click on a JAVA PROJECT - RIGHT CLICK EXPORT - NAME DESTINATION JAR
Run a Java Project
On the top of the eclipse IDE - Click RUN - RUN
change the font colors of your Java code
On the top of the eclipse IDE click menu- click on the WINDOWS-PREFERENCES-on the left-hand side - click on GENERAL-APPEARANCE-COLORS AND FONTS
View the settings preferences of your Java project
On the top of the eclipse IDE menu - Click on the WINDOWS and then PREFERENCES then select the preference setting of choice to view/change
Open your bookmarks view to you one of your bookmarked lines in your source code.
On the top of the eclipse IDE menu bar - Click - WINDOWS- SHOW VIEW - OTHER - GENERAL - BOOKMARKS . Your bookmarks will be shown at the end of the eclipse IDE. Click on each line to take you to the particular bookmark.
You close all projects and open project
On the top of the eclipse IDE menu bar - Click WINDOW - SHOW VIEW - PROJECT EXPLORER- RIGHT-CLICK project in list - OPEN PROJECT
how can you uninstall an eclipse plug-in?
On the top of the eclipse IDE menu bar-click HELP-ECLIPSE MARKETPLACE then click the INSTALLED tab and then uninstall the plug-ins of choice.
git show
Shows information about a git object. Example: git show commit 84f241e8a0d768fb37ff7ad40e294b61a99a0abe Author: User <[email protected]> Date: Mon May 3 09:24:05 2010 +0300 first commit diff --git a/README b/README new file mode 100644 index 0000000..e69de29
git status
Shows you the status of files in the index versus the working directory. It will list out files that are untracked (only in your working directory), modified (tracked but not yet updated in your index), and staged (added to your index and ready for committing). Example: git status # On branch master # # Initial commit # # Untracked files: # (use "git add <file>..." to include in what will be committed) # # README nothing added to commit but untracked files present (use "git add" to track)
Which statement about methods is true?
Some methods carry out an action; others return a value
9. The statement that best describes the portability characteristics of Java.
The same Java class files will run on different operating systems without change.
Images and music are contained in binary files. Answers: True False
True
What is the term we use to describe the creation of a class where we are including only related information.
encapsulation
In Java, a(n) _________ specifies the kind of values that can be stored in a variable
type
The do loop is a variation of the ____ loop.
while
In Java, objects within the same class share common _______.
behavior
Which is the Java equivalent of the following mathematical expression? c = (√a + √b)^2
c = Math.pow((Math.sqrt(a) + Math.sqrt(b)), 2);
Which is the Java equivalent of the following mathematical expression? c = √(a^2 + b^2)
c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2));
Given the definition final double PI = 3.14159; which of the following is the Java equivalent of the mathematical expression c = π ⋅ radius2
c = PI * Math.pow(radius, 2);
What is the output from the following print statements, assuming; String myString = "Testing"; Make sure all of your responses are in quotes, e.g. "Test". printf("%4s", myString);
"Testing" Strings longer than the specified width will be printed without truncation.
Save the current open Java project "My Java Project" as "My Java Project - Version 2"
#1 CLOSE on PROJECTS in eclipse and shutdown eclipse #2 GO TO the FOLDER where your project is stored on your computer #3 Make a COPY of this folder and call it "My Java Project - Version 2" #4 open eclipse and click FILE - IMPORT #5 General-Import Existing Projects into Workspace and press next #6 click Browse and locate your "My Java Project - Version 2" #7 Click Finish
Name the 4 major visible parts of an eclipse window.
#1 Views e.g.PACKAGE VIEW EXPLORE left-hand side window #2 EDITORS- #3 MENU BAR e.g. File-Edit-Navigate-Search #4 TOOLBAR e.g. icon shortcuts (Below Menu Bar)
What is the output of the following code: int num1 = 6; int num2 = 10; num1 = num1 + num2; num2 = num1 + num2; System.out.println(num1 + ", " + num2);
16, 26
What will be output from the following statements that use BankAccount class? BankAccount first = new BankAccount (100); BankAccount second = new BankAccount (100); BankAccount third = first; first.deposit (50.0); second.deposit (50.0); third.deposit (50.0); System.out.println (first.getBalance() + " " + second.getBalance() + third.getBalance()); A. 200.0 150.0 200.0 B. 250.0 250.0 250.0 C. 150.0 150.0 150.0 D. 150.0 200.0 250.0
200.0 150.0 200.0
Set up swing GUI design in eclipse using the WindowBuilder plug-in
#1 download WindowBuilder #2 unzip #3 on the top of the eclipse IDE menu bar click - HELP - INSTALL NEW SOFTWARE then select the location of the download "WindowBuilder" and follow the instructions for installation
How can you delete all bookmarks in a class
#1 top right-hand corner click OPEN PERSPECTIVE #2 kick Window/Show View/Bookmarks then delete the bookmarks accordingly
The _______ format specifier can receive any type of Java data.
%s
Fill in the correct letter for each format specifier: %__ for strings, %__ for integer values, %__ for decimal (floating point) values.
%s %d %f
The conditional AND operator in Java, C++, and C# is _____.
&&
Logical Operators
&& (AND), || (OR), ^ (XOR), ! (NOT)
15. Parameters to methods are enclosed by these symbols.
( )
B
. The repetition of a series of steps is called a(n) ____. a. repeat flow b. loop c. flow d. infinite loop
public class OutsideTemperatureFormatting { public static void main (String [] args) { double outsideTemperature; outsideTemperature = 103.46432; /* Your solution goes here */ } }
/* Your solution goes here */ System.out.printf("%.2f\n", outsideTemperature);
The Java compiler ignores any text between ____.
/* and */
Instance variables that are numbers are initialized to what default value? A. 0 B. nil C. Instance variables are not initialized to a default value. D. null
0
What is the output of the following code: int num1 = 6; int num2 = 10; num1 = num2; num2 = num1; System.out.println(num1 + ", " + num2);
10, 10
What output is produced by these statements? String name = "Joanne Hunt"; System.out.println(name.length());
11
What does the following statement sequence print if the user input is 123? public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter a number: "); String str = in.next(); str += 456; System.out.println(str); }
123456
Assume the class Circle has an accessor called getRadius and a mutator called setRadius. What is the output of the following code? Circle c1 = new Circle(3); Circle c2 = c1; c1.setRadius(4); System.out.println(c2.getRadius());
4
What is the output from the following print statements, assuming: float myFloat = 45.1342f; System.out.printf("%.3e", myFloat);
4.513e+01 ; e is used to display float values in scientific notation, .3 specifies the digits to print following the decimal point.
Assuming that the user enters 45 and 62 as inputs for n1 and n2, respectively, what is the output of the following code snippet? public static void main(String[] args) { System.out.print("Enter a number: "); Scanner in = new Scanner(System.in); String n1 = in.next(); System.out.print("Enter another number: "); String n2 = in.next(); String result = n1 + n2; System.out.print(result); }
4562
Output Formatting: public class OutputFormatting { public static void main(String[] args) { int myInt; myInt = 853; System.out.printf("%2d\n", myInt); System.out.printf("%4d\n", myInt); } }
853 853
12. In Java, every statement must end with this symbol.
;
Relation Operators
< , > , <= , >= , == , != (<>)
The assignment operator is the ____ sign.
=
what is before a JUnit test method
@test
D
A ____ allows users to interact with a program in a graphical environment. a. GCI b. CGI c. command line d. GUI
Boonlean
A ____ expression is one that represents only one of two states, usually expressed as true or False.
Which of the following statements about methods is correct? A) A method is a sequence of instructions that could access the data of an object B) A method name is unique across the entire program. C) A method can be called on any object in any class. D) Methods are stored in variables.
A) A method is a sequence of instructions that could access the data of an object
Cascading
A series of nested if statements is also called a ____ if statement.
Expression
A set of operands and operations that produce a mathematics based or logic based result. Concatenation, or joining of strings, is also considered an expression.
Which of the following represents a method declaration with a void return type? A) public void setValue(int value) { ... } B) public void int getValue() { ... } C) void public setValue(int value) { ... } D) void int getValue() { ... }
A) public void setValue(int value) { ... }
AND
A(n) ____ decision is a decision in which two conditions must be true for an action to take place.
C
A(n) ____ is a location on your computer screen where you type text entries to communicate with the computer's operating system. a. input line b. communication line c. command line d. GCI
A
A(n) ____ is a program that you use to create simple text files. a. text editor b. IDE c. GUI d. GDE
B
A(n) ____ is a repeating flow of logic with no end. a. nonterminated condition b. infinite loop c. variable d. decision symbol
A JPanel is an object ...
we use to draw on
A JFrame is an object ...
we use to pop up a window
Runtime errors can be caused by
• *Program bugs* • Bad or unexpected input • Hardware or software problems in the computer system (very rare)
Hints to help find/fix runtime errors:
• Check the exception message for the method and line number from which it came • Note that the line in the code that caused the exception may not be the line with the error • Example: consider the code segment int [] nums = new int[10]; for (int j=0; j<=10; j++) nums[j] = j; • The exception will be at the line nums[j] = j; but the error is in the previous line
Program Errors
• Compiler errors (syntax errors) • Runtime errors • Logic errors
Hints to help find/fix compiler errors:
• Compiler errors are cumulative: when you fix one, others may go away • Read the error messages issued by the compiler • Realize that the error messages from the compiler are often (seemingly) not very helpful • The compiler does not know what you intended to do, it merely scans the Java code
Compiler Errors are Very common (but sometimes hard to understand). Examples of syntax errors:
• Forgetting a semicolon • Leaving out a closing bracket } • Redeclaring a variable
Tracing by hand
• Good starting point for small programs or simple methods • Problem: sometimes you do what you think the computer will do, but that is not what it actually does -Example: you may write that int i = 9/5; assigns to i the value 1.8, but it is really 1 • Hint: draw diagrams of reference variables and what object(s) they are pointing to
Debugging Strategies
• Trace your code by hand • Add main method to the class • Add print statements to your code • Use a debugger
All Integrated Development Environments have an *interactive debugger* feature, you can...
• You can *single-step* step through your code (one statement at a time) • You can see what is stored in variables • You can set *breakpoints* • You can "*watch*" a variable or expression during execution
Common logic errors are:
• using == instead of the equals method • infinite loops • misunderstanding of operator precedence • starting or ending at the wrong index of an array • If index is invalid, you would get an exception • misplaced parentheses (so code is either inside a block when it shouldn't be, or vice versa) • Be careful of where you declare variables. -Keep in mind the scope of variables -Example: private int numStudents; // an attribute, to be initialized in some method ... public void someMethod(){ int numStudents = ...; // not the instance variable! ... }
git log -Sfunction_name
Another really helpful filter is the -S option which takes a string and only shows the commits that introduced a change to the code that added or removed that string.
What is the name of the type that denotes whole numbers? A) double B) int C) whole D) integer
B) int
Which statement declares and stores an integer value in a variable? A) count = 5; B) int count = 5; C) integer count = 5; D) String count = 5;
B) int count = 5;
The input to a method is called a(n) _______________. A) overloaded B) parameter C) interface D) procedure
B) parameter
What is the term used to specify the remote control for a class, indicating what you can do with the objects that belong to the class? A) private interface B) public interface C) private implementation D) hidden implementation
B) public interface
Which method would you use to obtain the string "1234567890" from the string "123-456-7890"? A) isEmpty B) replace C) trim D) length
B) replace
Which of the following is a mutator method for the Rectangle class? A) getHeight B) translate C) getWidth D) isEmpty
B) translate
Shift Operators
Bitwise operators in programming which shift the binary bits of a value either to the left or to the right.
git push origin [tagname]
By default, the git push command doesn't transfer tags to remote servers. You will have to explicitly push tags to a shared server after you have created them
Assume that the variable count has been declared as type int. Which statement adds 10 to count? A) count = 10; B) count == count + 10; C) count = count + 10; D) count + 10;
C) count = count + 10;
Input to a method enclosed in parentheses after the method name is known as ______________. A) implicit parameters B) interfaces C) explicit parameters D) return values
C) explicit parameters
Which method call represents the invocation of a method that does not have explicit parameters? A) greeting.replace("Hello", "Welcome"); B) greeting.length C) greeting.length() D) System.out.println(greeting);
C) greeting.length()
Which term is used to describe the name of a variable, method, or class? A) type B) literal C) identifier D) label
C) identifier
The object on which the method call is invoked provides input to the method, and is called a(n) _________________. A) interface B) procedure C) implicit parameter D) explicit parameter
C) implicit parameter
Which of the following code fragments will cause an error? A) String greeting = "Hello, Dave!"; B) String greeting = "Hello, World!"; int n = greeting.length(); C) int luckyNumber; System.out.println(luckyNumber); D) PrintStream printer = System.out;
C) int luckyNumber; System.out.println(luckyNumber);
By convention, variables begin with a(n) _____________. A) uppercase letter B) digit C) lowercase letter D) dollar sign
C) lowercase letter
What terminology describes a method that modifies the internal data of its implicit parameter? A) public B) void C) mutator D) accessor
C) mutator
What is the declared return type for a method that does not have a return value? A) String B) There is no declared return type when a method does not return a value. C) void D) A method must return a value.
C) void
Which statement declares a variable that references a Circle of radius 3, assuming the construction parameter is the radius value?
Circle c = new Circle(3);
A _______ is a term that describes objects with common attributes.
Class
A(n) _____ is just an abstract description of what an object will be like if any objects are ever actually instantiated.
Class
Everything is an object, and every object is a member of a _____.
Class
A _______ is a set of programs statements that tells you the characteristics of the class's objects and the methods that can be applied to its objects.
Class definition
Programmers often use a ________ to illustrate class features or to help plan them.
Class diagram
A program or class that instantiates objects of another prewritten class is a class client or _______
Class user
Close the project because it __________ __________. To do this - _____
Close the project because it CONSUMES MEMORY. To do this on the left-hand side of the eclipse IDE - RIGHT-CLICK the PROJECT and LEFT CLICK .
What is the type of an object? A) variable B) method C) reference D) class
D) class
Which method checks whether a point lies within the rectangle? A) add B) getBounds C) translate D) contains
D) contains
A method name is ____________________ if a class has more than one method with that name (but different parameter types). A) overridden B) overimplemented C) overwhelmed D) overloaded
D) overloaded
A set of values and the operations that can be carried out with those values are called _______. A) literals B) numbers C) values D) types
D) types
By convention, classes begin with a(n) _____________. A) lowercase letter B) dollar sign C) digit D) uppercase letter
D) uppercase letter
What is a storage location in the computer's memory called that has a type, name, and contents? A) identifier B) literal C) label D) variable
D) variable
A statement that provides a data type and an identifier for a variable.
Declaration
b) Change line 9 to: public static void MAIN(String[] args) {
Different program output: The program would not run because Java would be unable to find the main method.
c) Insert a new line after line 11 that reads: System.out.println();
Different program output: There would now be a blank line between the two printed messages.
git diff
Doesn't show all changes made since your last commit - only changes that are still unstaged. This can be confusing, because if you've staged all of your changes, git diff will give you no output.
Example output formatting for Strings. public class DogAge { public static void main(String[] args) { System.out.printf("Dog age in human years (dogyears.com)\n\n"); System.out.printf("-------------------------\n"); // set num char for each column, left justified System.out.printf("%-10s | %-12s\n", "Dog age", "Human age"); System.out.printf("-------------------------\n"); // set num char for each column, first col left justified System.out.printf("%-10s | %12s\n", "2 months", "14 months"); System.out.printf("%-10s | %12s\n", "6 months", "5 years"); System.out.printf("%-10s | %12s\n", "8 months", "9 years"); System.out.printf("%-10s | %12s\n", "1 year", "15 years"); System.out.printf("-------------------------\n"); } }
Dog age in human years (dogyears.com) ------------------------- Dog age | Human age ------------------------- 2 months | 14 months 6 months | 5 years 8 months | 9 years 1 year | 15 years -------------------------
A flowchart is an English-like representation of the logical steps necessary to solve a problem.
False
A program or class that instantiates methods of another prewritten class is a class client or class user.
False
A structured program must contain a sequence, selection, and loop structure.
False
Alan Turing is often regarded as the first programmer.
False
All programming languages support four broad data types.
False
Any decision can be made using combinations of just two types of comparisons: equal and not equal. (T/F)
False
Declaring a class creates actual objects.
False
In addition to their attributes, classes have methods associated with them, and every object instantiated from a given class possesses different methods. Answers: True False
False
Modularization makes it harder for multiple programmers to work on a problem.
False
Most modern programming languages require that program statements be placed in specific columns.
False
Most programming languages limit the number of AND and OR operators in an expression.
False
No matter how complicated it is, any set of steps can always be reduced to combinations of the two basic structures of sequence and loop.
False
Once a program is completely coded, it is ready for a company or organization to use.
False
Professional computer programmers write programs to satisfy their own needs.
False
Programmers generally write programs as one long series of steps.
False
Repetition and sequence are alternate names for a loop structure.
False
Software can be classified into two broad types: application software and programming software.
False
Structured programs use spaghetti code logic.
False
The assignment operator has left-to-right-to-left associativity, which means that the value of the expression to the left of the assignment operator is evaluated first and that the result is assigned to the operand on the right.
False
When you combine AND and OR operators, the OR operators take precedence, meaning their boolean values are evaluated first.
False
When you copy data from RAM into a file on a storage device, you read to the file. Answers: True False
False
When you need to satisfy two or more criteria to initiate an event in a program, you must make sure that the second decision is made entirely independently of the first decision.
False
When you think in an object-oriented manner, everything is an object, and every object is a member of a method.
False
tracked files
Files that were in the last snapshot (they can be unmodified, modified, or staged). Untracked basically means that Git sees a file you didn't have in the previous snapshot (commit).
List five important features of object-oriented languages.
Five important features of object-oriented languages are: • Classes • Objects • Polymorphism • Inheritance • Encapsulation
What does %f used for?
Multiple format specifiers can appear within the format string. The %f is used for printing floating-point values, such as float and double. The value stored within the variable years will be printed as a decimal integer in place of the %d format specifier, and the value stored within the variable total will be displayed as a double.
What is the difference between the file MyProgram.java and the file MyProgram.class? - The programmer writes the .class file first, and the .java file is generated automatically later. - MyProgram.java is a source code file typed by the programmer, and MyProgram.class is a compiled executable class file that is run by the computer. - The .class file is for object-oriented programming and the .java file is for procedural programming. - A .java file is a much larger binary file and a .class file is a smaller compressed version. - A .java file contains code written in the Java language, and a .class file contains code written in the C++language.
MyProgram.java is a source code file typed by the programmer, and MyProgram.class is a compiled executable class file that is run by the computer.
Placing a structure within another structure
Nesting structure
e) Change line 2 to: public static void showMessage() {, and change lines 11 and 12 to: showMessage();
No effect: The program would still compile successfully and produce the same output.
Why do computers use binary numbers? - Because there are 10 types of people: Those who understand binary, and those who don't. - It makes the computer faster and more efficient than other number bases. - It is easier to build electronic devices reliably if they only have to distinguish between two electric states. - At the time when computers were invented, humans only knew about the numbers 0 and 1.
It is easier to build electronic devices reliably if they only have to distinguish between two electric states.
Shortcut Operators
Operators that combine the operation and assignment process into one operation, such as +=, -=, *=, or /=.
Incorrectly spelled words, or reversing the proper order of two words in a computer program
Sintax error
git log --pretty=oneline git tag -a v1.2 9fceb02
Tagging Later
git tag
Tags a specific commit with a simple, human readable handle that never moves. Example: git tag -a v1.0 -m 'this is version 1.0 tag'
git commit
Takes all of the changes written in the index, creates a new commit object pointing to it and sets the branch to point to that new commit. Examples: git commit -m 'committing added changes' git commit -a -m 'committing all changes, equals to git add and git commit'
git stash
Temporarily saves changes that you don't want to commit immediately. You can apply the changes later. Example: git stash Saved working directory and index state "WIP on master: 84f241e first commit" HEAD is now at 84f241e first commit (To restore them type "git stash apply")
Which of the following statements about test programs is true?
Test programs verify that methods have been implemented correctly.
What does %d format specifier indicate in the previous example? System.out.printf(" You know %d people.\n", totalPpl);
The %d format specifier in the example above indicates that the printf() statement should output a decimal integer value. Specifically, the % indicates we would like to output a value stored within a variable, and the d indicates how we would like that value to be displayed as a decimal integer. Following the format string (separated by a comma), the variable total indicates that the value stored within this variable will be printed in place of the %d format specifier.
An infinite loop is a flow of program logic that repeats and never ends.
True
As a general rule, an eof question should always come immediately after an input statement because the end-of-file condition will be detected at input.
True
Because one memory location can be used repeatedly with different values, you can write program instructions once and then use them for thousands of separate calculations
True
Because you may stack and nest structures while retaining the overall structure, it might be difficult to determine whether a flowchart as a whole is structured.
True
Besides AND and OR operators, most languages support a NOT operator.
True
Besides the popular, comprehensive programming languages such as Java and C++, many programmers use scripting languages such as Python, Lua, Perl, and PHP.
True
Class diagrams consists of a rectangle divided into three sections. Answers: True False
True
Creating multiple methods with the same name, which will act differently and appropriately when used with different types of objects, is known as polymorphism.
True
Declaring a class does not create actual objects. Answer: True False
True
Every decision you make in a computer program involves evaluating a Boolean expression. (T/F)
True
Every programming language has rules governing its word usage and punctuation.
True
Files in which records must be accessed immediately are sometimes called instant access files. Answers: True False
True
In a structured program, any structure can be nested within another structure.
True
In addition to their attributes, class objects have methods associated with them, and every object that is an instance of a class possesses that same methods.
True
In any Boolean expression, the two values compared can be either variables or constants.
True
In any boolean expression, the two values compared can be either variables or constants. (T/F)
True
In many programming languages, if you declare a variable and do not initialize it, the variable contains an unknown value until it is assigned a value.
True
The heart of the programming process lies in planning the program's logic.
True
The purpose of set methods is to set the values of data fields within the class
True
The terms "parent" and "child" can refer to file backup generations, but they are also used for a different purpose in object-oriented programming. Answers: True False
True
You can use parentheses to override the default order of operations.
True
How are the keyboard and monitor used in most programming languages?
Most programming languages allow you to read data from a keyboard or write it to the display monitor without having to issue open or close commands because the keyboard and monitor are the default input and output devices, respectively.
Inside your Java source code of the eclipse IDE - you already have an attribute called "visa_number" you want to call this again somewhere down the code - how can you efficiently call this new variable without having to type it out fully again
Type the first few letters of the variable e.g. vi and then press the CTRL + SPACEBAR - it will give you a list of auto complete suggestions - choose the "visa_number"
When are local variables initialized? A. You must initialize local variables in the constructor. B. You must initialize local variables in a method body. C. Local variables are initialized when the method is called. D. Local variables are initialized with a default value before a constructor is invoked.
You must initialize local variables in a method body.
C
You represent a decision in a flowchart by drawing a decision symbol, which is shaped like a ____. a. parallelogram b. square c. diamond d. circle
What is the name of the type that denotes a string of characters?
String
Which class is part of the java.lang package?
String
Can hold text, such as letters of the alphabet, and other special characters, such as punctuation marks.
String Variable
Can hold text, such as letters of the alphabet, and other special characters, such as punctuation marks
String variable
Which of the following declares a variable that will store a welcome message?
String welcome;
%s
String; Prints the characters in a String variable or literal.
A basic unit of programming logic
Structure
d
Suppose a phone number, stored as a ten-character string (of digits only) called phoneNumber, must be converted into a string that has parentheses around the area code. Which statement below will do that? a) String newNumber = "(" + phoneNumber.substring(3, 0) + ")"; b) String newNumber = "(" + ")" + phoneNumber; c) String newNumber = "(" + phoneNumber.substring(1, 3) + ")" + phoneNumber.substring(3, 7); d) String newNumber = "(" + phoneNumber.substring(0, 3) + ")" + phoneNumber.substring(3, 10);
4.
Switch Eclipse from Debug Perspective back to Java Perspective. • Click on the Java Perspective button
____ errors are relatively easy to locate and correct because the compiler or interpreter you use highlights every error.
Syntax
a) Change line 1 to: public class Demonstration
Syntax error: The program would not compile because its class name (Demonstration) would not match its file name (Example.java).
d) Change line 2 to: public static void printMessage() {
Syntax error: The program would not compile because the main method would be calling a method (displayRule) that no longer existed.
Private instance variables ___. a) can only be accessed by methods of a different class b) can only be accessed by methods of the same class c) cannot be accessed by methods of the same class d) can only be accessed by the constructor of the class
b) can only be accessed by methods of the same class
Consider the following invocation of the deposit method: mySavings.deposit(250); What is the implicit parameter? a) deposit b) mySavings c) 250 d) There is no implicit parameter.
b) mySavings
The input to a method is called a(n) _______________. a) overloaded b) parameter c) interface d) procedure
b) parameter
A ____ is a rectangular object you can click; when you do, its appearance usually changes to look pressed
buttom
Which of the following is the Java equivalent of the following mathematical expression? c = 2π ⋅ radius
c = 2 * Math.PI * radius;
Instance variables that are numbers are initialized to what default value? a) Instance variables are not initialized to a default value. b) nil c) 0 4) null
c) 0
Consider the following invocation of the deposit method: mySavings.deposit(250); What is the explicit parameter? a) There is no explicit parameter. b) deposit c) 250 d) mySavings
c) 250
What will be output from the following statements that use BankAccount class? BankAccount first = new BankAccount (100); first.deposit (50.0); BankAccount second = new BankAccount (first.getBalance()); first.deposit (50.0); BankAccount third = new BankAccount (first.getBalance()); first.deposit (50.0); System.out.println (first.getBalance() + '' '' + second.getBalance() + third.getBalance()); a) 150.0 200.0 250.0 b) 250.0 250.0 250.0 c) 250.0 150.0 200.0 d) 250.0 200.0 250.0
c) 250.0 150.0 200.0
What is the output of the following code snippet? public static void main(String[] args) { int value = 3; value++; System.out.println(value); } a) 2 b) 3 c) 4 d) No output due to syntax error
c) 4
If an exception is thrown, it is passed to a block of code that can ____, which means to receive it in a block that can handle the problem.
catch the exceptiom
data type is a single 16-bit Unicode character.
char
%c
char ; Prints a single Unicode character.
Which one of the following statements can be used to get the fifth character from a string str?
char c = str.charAt(4);
%c
character
22. The Java compiler translates source code into what type of file?
class
The class constructor always has the same name as __. A. instance variable B. parameter variable C. access specifier D. class
class
The type of an object is given by its ______ ?
class
What is the output of the following code snippet? String firstname = "William"; String lastname; System.out.println("First: " + first); System.out.println("Last: " + lastname);
code will not compile
After a programmer plans the logic of a program, the next step is ____.
coding the program
A(n) ____ is a location on your computer screen where you type text entries to communicate with the computer's operating system.
command line
The ____ is the location on your computer screen at which you type entries to communicate with the computer's operating system.
command line
Performing an operation on an icon causes a(n) ____.
event
You should provide documentation comments for ___ A. every class, every method, every parameter, and every return value B. only methods with parameters C. only classes D. only methods with return values
every class, every method, every parameter, and every return value
In object-oriented terminology, the generic name used for errors is ____.
exceptions
29. A step sequence that can be carried out in practice is _____.
executable
An abstract class is one from which you can create any concrete objects and from which you can inherit
false
An abstract method cannot have parameters
false
Any decision can be made using combinations of just two types of comparisons: equal and not equal.
false
If you have an abstract class, you must include at least 1 abstract method
false
In Eclipse, if you close tabs that you want to reestablish (e.g., you close the Tasks and Outline tabs) the easiest way to reset your perspective is to select the "reset perspective" option in your menu.
false
In Eclipse, like Dr. Java, .java and .class files are located in the same folder
false
In OOP languages, a default constructor is created automatically by the compiler for every class you write.
false
In object-oriented languages, the procedural modules that depend on user-initiated events are often called applets.
false
JUnit means "Java Unit Testing" that is a blanket meaning for any testing done in Java
false
Setters are used to make sure the class returns the correct property
false
When a java file is added to a project it is placed in a package (by default) with the same name as the file you are adding. So, for example, say you add a .java file called "Calculator.java" to your project. It will be placed in a "calculator" package.
false
When you combine AND and OR operators, the OR operators take precedence, meaning their Boolean values are evaluated first.
false
When you need to satisfy two or more criteria to initiate an event in a program, you must make sure that the second decision is made entirely independently of the first decision.
false
When you program in a language that uses GUI components, you need to create them from scratch.
false
You can use the ctrl-spacebar to fix spelling mistakes (well, it will pop up with suggestions - not actually change the spelling)
false
13. What term used to refer to text in a program that helps human readers understand the program?
comments
What term is used to refer to text in a program that is an explanation for human readers of the code?
comments
When you purchase or download a(n) ____ for an object-oriented programming language, it comes packaged with many predefined, built-in classes.
compiler
Typically, a programmer develops a program's logic, writes the code, and ____ the program, receiving a list of syntax errors.
compiles
Which part of a class implementation contains the instructions to initialize an object's instance variables? A. initializer B. constructor C. type name D. access specifier
constructor
The ____ contains methods that allow you to set physical properties such as height and width, as well as methods that allow you to add the appropriate components to a container.
container class
Which statement stores an integer value in a variable?
count = 5;
Assuming that the variable count has been declared as type int, which statement changes the value of count?
count = 6;
Assume that the variable count has been declared as type int. Which statement adds 10 to count?
count = count + 10;
You cannot provide parameters to a destructor; it must have an empty parameter list.
false
In a truth table, the expression __________ is false.
false OR false
Which one of the following statements defines a constant with the value 123? Correct!
final int MY_CONST = 123;
For maximum efficiency, a good rule of thumb in an AND decision is to _______.
first ask the question that is more likely to be false
For maximum efficiency, a good rule of thumb in an OR decision is to _________.
first ask the question that is more likely to be true
%e
float, double; Prints a floating-point value in scientific notation.
%f
float, double; Prints a floating-point value.
%a
floating point index
Fractional numeric variables that contain a decimal point are known as ____ variables.
floating-point
The first parameter of the printf method is called the _____ ______
format string
Complete this code fragment to ensure that the frame is shown: JFrame frame = new JFrame();
frame.setVisible(true);
After resolving conflicts, merge with
git add $conflicting_file git rebase --continue
git add
git add is a multipurpose command - you use it to begin tracking new files, to stage files, and to do other things like marking merge-conflicted files as resolved ( "add this content to the next commit")
Update: Apply a patch that someone sent you
git am -3 patch.mbox
Show: Who changed what and when in a file
git blame $file
Branch: Create branch named $branch based on the HEAD
git branch $branch
Branch: Delete $branch
git branch -d $branch
Branch: Merge branch1 into branch2
git checkout $branch2 git merge branch1
Branch: Switch to the $id branch
git checkout $id
Revert: Checkout the $id version of a file
git checkout $id $file
Branch: Create branch $new_branch based on branch $other and switch to it
git checkout -b $new_branch $other
Revert: Fix the last commit
git commit -a --amend
Show: changes to tracked files
git diff
To view merge conflicts
git diff git diff --base $file git diff --ours $file git diff --theirs $file
Show: What changed between $ID1 and $ID2
git diff $id1 id2
Publish: Prepare a patch for other developers
git format-patch origin
Check for errors and cleanup repository
git fsck git gc --prune
Revert: Revert the last commit
git revert HEAD
Show: A commit identified by $ID
git show $id
Show: A specific file from a specific @ID
git show $id:$file
If greeting is a String object, which method call is incorrect?
greeting.println()
Which of the following is the mathematical equivalent of the following Java expression? h = (4.0 * a * b - Math.pow(b, 2)) / c;
h = (4ab - b2) / c
4. Which type of secondary storage consists of rotating platters, which are coated with a magnetic material, and read/write heads
hard disk
The "building blocks" that Java programmers use to write computer programs are called _______.
objects
%%
inserts percent sign
In an airline reservation system, the number of available seats in an airplane is required. Which data type should be used to store this value?
int
is a 32-bit signed two's complement integer, which has a minimum value of -231 and a maximum value of 231-1.
int
Which statement declares and stores an integer value in a variable?
int count = 5;
Which of the following declares a variable that will store a count with an integer value?
int count;
%o
octal integer
Create your own auto complete shortcut for writing the block of code try{ }catch(){ } so that when you type t followed by CTRL+SPACEBAR gets printed
on the top of the eclipse IDE menu bar click WINDOW- PREFERENCES- on the left-hand side click JAVA-EDITOR-TEMPLATES within the click NEW button and create your new auto complete shortcut for try{ }catch(){ }
A method name is ____________________ if a class has more than one method with that name (but different parameter types).
overloaded
A(n) _____________ is a collection of classes with a related purpose.
package
Drawing instructions should be placed inside the ____ method, which is called whenever the component needs to be repainted.
paintComponent
The ____ is used to represent output in a flowchart.
parallelogram
You can use ____ for clarity and to override the default order of operations
parentheses
The assignment operator
places a new value into a variable
When you develop an event-driven application, you need to expand on the ____ step in the program development cycle.
planning of the logic
You can locate a plug-in that provides certain functionality by searching the ______ _______ ______
You can locate a plug-in that provides certain functionality by searching the ECLIPSE MARKETPLACE
Parentheses
You can use ____ for clarity and to override the default order of operations.
You can use bookmarks to serve as __________ and quickly __________ to any line in a file.
You can use bookmarks to serve as REMINDERS and quickly NAVIGATE to any line in a file.
subspecifier: .precision: example:
printf("%.4f", myFloat); 12.3400 printf("%3.4e", myFloat); 1.2340e+01
subspecifier: width; example;
printf("Value: %7.2f", myFloat); Value: 12.34
17. What is the name of the method in the given method call? System.out.println("Welcome");
println
Write a println statement that produces the following output: / \ // \\ /// \\\
println statement to produce desired output: System.out.println("/ \\ // \\\\ /// \\\\\\");
The following pseudocode is an example of a ____ structure. get number while number is positive add to sum get number endwhile
loop
The action or actions that occur within a loop are known as a(n) ____.
loop body
A loop must return to the ____ question at some later point in a structure.
loop-controlling
What term is used to refer to the computer instructions that are executed by a CPU?
machine code
git push [remote-name] [branch-name]
push data to remote
The following pseudocode is an example of a ____ structure. if firstNumber is bigger than secondNumber then print firstNumber else print secondNumber endigf
decision
The process of naming program variables and assigning a type to them is called ____ variables.
declaring
GUI programmers sometimes refer to screen space as ____.
real estate
In a flowchart, the ____ is used to represent processing.
rectangle
In object-oriented languages, the procedural modules that depend on user-initiated events are often called ____.
scripts
The process of walking through a program's logic on paper before you actually write the program is called ____.
desk-checking
A method's name and a list of argument types together are its ____.
signature
You represent a decision in a flowchart by drawing a decision symbol, which is shaped like a ____.
diamond
Which of the following declares a variable that will store a measurement with fractional parts?
double measure;
1. Add breakpoints:
double-click the blue bar on the left side of Edit window or right click on the bar and select "toggle breakpoint". A blue dot indicates a breakpoint. To remove a break point, double click the breakpoint
if-else examples can also be called ____ because they contain the action taken when the tested condition is true and the action taken when it is false.
dual-alternative selections
Pseudocode uses the end-structure statement ____ to clearly show where the structure ends.
endif
Structures can be stacked or connected to one another at their ____.
entry or exit points
Many programming languages use the term ____ to refer to the marker that is used to automatically recognize the end of data in a file.
eof
Which of the following constructs a Circle of radius 3, assuming the construction parameter is the radius value?
new Circle(3)
Depending on the programming language being used, modules are also known as ____ .
subroutines, procedures, or methods
The camel case naming convention uses _________ at intervals in the middle of the variable name.
uppercase letters
What is a storage location in the computer's memory called that has a type, name, and contents?
variable
When you write programs, you work with data in three different forms: ____.
variables, literals (or unnamed constants), and named constants
What is the declared return type for a method that does not have a return value?
void
Formatting Integer values:
Formatting of integer values can also be done using sub-specifiers. The behavior of sub-specifiers for integer data behave differently than for floating-point values. For the following assume myInt is an int value of 301.
When creating a truth table, you must determine how many possible Boolean value combinations exist for the conditions. If there are two conditions, ______ combinations will exist.
Four
A ____ allows users to interact with a program in a graphical environment.
GUI
A case in which no action is taken
Null case
How can you display all of the shortcut keys in eclipse IDE?
On the top of the eclipse IDE menu bar click HELP-KEY ASSIST (CTRL+SHIFT+L)
The following pseudocode is an example of a ____ structure. get firstNumber get secondNumber add firstNumber and secondNumber print result
Secuence
AND
When you combine AND and OR operators, the ____ operators take precedence, meaning their Boolean values are evaluated first.
OR
When you use the logical ____ operator, only one of the listed conditions must be met for the resulting action to take place.
d
Which of the following is the Java equivalent of the following mathematical expression? c = 2 radius a) c = 2 * Math.PI * radius * 2; b) c = 2 * Math.PI * Math.pow(2, radius); c) c = 2 * Math.PI * Math.pow(radius, 2); d) c = 2 * Math.PI * radius;
a
Which of the following options is valid with reference to the code snippet? public static void main(String[] args) { double d = 45.326; double r = d % 9.0; System.out.println(r); } a) The value inside the variable r will be 0.326 b) The value inside the variable r will be 5.036 c) Variable r has to be defined as an integer because the % operator always returns an integer d) The initialization of variable r is wrong, because the % operator expects integer values as operands
c
Which of the following statements displays price = 20.00 a) System.out.print("price = "); System.out.printf(price); b) System.out.print("price = "); System.out.printf("%f", price); c) System.out.print("price = "); System.out.printf("%10.2f", price); d) System.out.print("price = ");
c
Which one of the following refers to a number constant that appears in code without explanation? a) Constant b) Variable c) Magic number d) String literal
c
Which one of the following statements can be used to convert a string str to a double? a) double n = str.parseDouble(); b) double n = Integer.parseDouble(str); c) double n = Double.parseDouble(str); d) double n = double.parseDouble(str);
git pull
You can use this command to automatically fetch and then merge a remote branch into your current branch
NOT
You use the logical ____ operator to reverse the meaning of a Boolean expression.
Truth tables
____ are diagrams used in mathematics and logic to help describe the truth of an entire expression based on the truth of its parts.
B
____ errors are relatively easy to locate and correct because the compiler or interpreter you use highlights every error. a. Logic b. Syntax c. Input d. Process
logical operators
are used to evaluate two expressions && AND || OR ! NOT
Compiler Errors
*Syntax errors* • Errors in usage of Java • Detected by the compiler • A program with compilation errors cannot be run *Syntax warning* • Warning message generated by the compiler • The program can be run
Output formatting for integers: public class CelestialBodyDist { public static void main(String[] args) { final long KM_EARTH_TO_SUN = 149598000; // Dist from Earth to sun final long KM_SATURN_TO_SUN = 1433449370; // Dist from Saturn to sun // Output distances with min number of characters System.out.printf("Earth is %12d", KM_EARTH_TO_SUN); System.out.printf(" kilometers from the sun.\n"); System.out.printf("Saturn is %11d", KM_SATURN_TO_SUN); System.out.printf(" kilometers from the sun.\n"); } }
Earth is 149598000 kilometers from the sun. Saturn is 1433449370 kilometers from the sun.
You use the logical ______ operator to reverse the meaning of a Boolean expression.
NOT
git remote rm [remote-name]
Remove remote
git remote rename name to_name
Rename remote
Consider the following program, saved into a file named Example.java: 1 public class Example { 2 public static void displayRule() { 3 System.out.println("The first rule "); 4 System.out.println("of Java Club is,"); 5 System.out.println(); 6 System.out.println("you do not talk about Java Club."); 7 } 8 9 public static void main(String[] args) { 10 System.out.println("The rules of Java Club."); 11 displayRule(); 12 displayRule(); 13 } 14 }
What would happen if each of the following changes were made to the Example program? If there would be no change to the program, choose "nothing". If it would cause the program not to compile, choose "error". If it would change the program's output, choose "output". Treat each change independently of the others.
d. close
When you ____ a file, it is no longer available to your application. Answers: a. rewrite b. examine c. index d. close
The keyword that is NOT included in a single-alternative selection is ____.
else
A string variable can hold digits such as phone numbers and zip codes.
True
A this reference is an automatically created variable that holds the address of an object and passes it to an instance method whenever the method is called.
True
What is the output from the following print statements, assuming; String myString = "Testing"; Make sure all of your responses are in quotes, e.g. "Test". printf("%.10s", myString);
"Testing" A maximum of 10 characters can be printed, only 7 characters were needed.
A(n) ______ is one instance of a class.
Object
What do object variables store? a) objects b) classes c) references d) numbers
c) references
What is the type of an object? a) variable b) method c) reference d) class
d) class
Very common runtime errors are:
*Null reference (NullPointerException)* • no object is referenced by the reference variable, i.e. it has the value *null* *Array index out of bounds* (ArrayIndexOutOfBoundsException) ArrayIndexOutOfBoundsException is thrown to indicate that we are trying to access array element with an illegal index. This exception is thrown when the index is either negative or greater than or equal to the size of the array. Running out of memory • e.g. from creating a new object every time through an infinite loop
Testing vs Debugging
*Testing:* to identify any problems before software is put to use • "Testing can show the presence of bugs but can never show their absence" *Debugging:* locating bugs and fixing them
Arithmetic Operator
+ for plus, - for minus, * for multiplication, / for division, and % for modulus
What is the output from the following print statements, assuming;int myInt = -713; printf("%+04d", myInt); printf("%05d", myInt);
-0713 ;There are total of 5 characters printed: one character for the - sign, one character for the 0 used to pad the printed value, and 3 characters for the value 713.
What is the output from the following print statements, assuming;int myInt = -713; printf("%+02d", myInt);
-713 ; myInt is a negative value, so a - sign is printed for all negative values. If the formatted value has more characters than the width, it will not be truncated.
What is the output from the following print statements, assuming; int myInt = -713;
-713 ;myInt is a negative value, so the + sign is not printed. A - sign is printed for all negative values.
subspecifier: flags:
-: Left justifies the output given the specified width, padding the output with spaces. +: Print a preceding + sign for positive values. Negative numbers are always printed with the - sign. 0: Pads the output with 0's when the formatted value has fewer characters than the width. space: Prints a preceding space for positive value.
What is the output from the following print statements, assuming: float myFloat = 45.1342f; System.out.printf("%09.2f", myFloat);
000045.13 ; There are total of 9 characters printed: 6 digits before the decimal point, the decimal point, and 2 digits after the decimal point. The 0 pads the output with 0's when the formatted value has fewer characters than the width.
The printf method of the System.out object requires at least _____ parameters.
2
Assuming that the user enters 23 and 45 as inputs for num1 and num2, respectively, what is the output of the following code snippet? public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter a number: "); String num1 = in.next(); System.out.print("Enter another number: "); String num2 = in.next(); System.out.println(num1 + num2); }
2345
What is the output of the following code snippet? public static void main(String[] args) { double x; x = Math.pow(3.0, 2.0) + Math.pow(4.0, 2.0); System.out.println(x); }
25.0
What is the output of the following code: Circle c1 = new Circle(3); Circle c2 = new Circle(3); c1.setRadius(4); System.out.println(c2.getRadius());
3
What does the following statement sequence print if the user input is 123? public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter a number "); int myInt = in.nextInt(); myInt += 456; System.out.println(myInt); }
579
What is the output of the following code: int num1 = 6; int num2 = num1; num2 = num2 + 10; System.out.println(num1);
6
A __________ is an intentional stopping or __________ place in a program, put in place for debugging purposes.
A BREAKPOINT is an intentional stopping or PAUSING place in a program, put in place for debugging purposes.
Which of the following statements about classes is correct?
A class declares the methods that you can apply to its objects.
List the three parts of a class definition.
A class definition can contain three parts: • Every class has a name. • Most classes contain data, although this is not required. • Most classes contain methods, although this is not required.
What is the return type of a constructor? A. private B. public C. A constructor does not have a return type. D. void
A constructor does not have a return type.
Explain a format specifier:
A format specifier begins with the % character followed by a sequence of characters that indicate the type of value to be printed.
1. The statement that best describes a computer program.
A program is a sequence of instructions and decisions that the computer carries out.
Which statement best describes a computer program?
A program is a sequence of instructions and decisions that the computer carries out.
A programmer can adjust the way that output appears, know as_____.
A programmer can adjust the way that output appears, a task known as output formatting.
What is a local variable? A. A variable that is declared in the body of the class. B. A variable that is declared in the header of a method. C. A variable that is declared in the body of a method. D. A variable that is declared in the header of a class.
A variable that is declared in the body of a method.
What is a parameter variable? A. A variable that is declared in the header of a class. B. A variable that is declared in the body of the class. C. A variable that is declared in the header of a method. D. A variable that is declared in the body of a method.
A variable that is declared in the header of a method.
7. What is the JVM?
A virtual machine that runs compiled Java code on any CPU.
Binary
A word that is used to describe the base 2 number system. A type of operator that performs a calculation on two operands (+, -, *, /, %) or two input elements to work.
Which statement calls a constructor with no construction parameters? A) Circle c = new Circle(); B) A call to a constructor must have construction parameters. C) Circle c = new Circle; D) Circle c = Circle()
A) Circle c = new Circle();
Which of the following declares a variable that will store a welcome message? A) String welcome; B) double welcome; C) Char welcome; D) int welcome;
A) String welcome;
Which of the following statements about test programs is true? A) Test programs verify that methods have been implemented correctly. B) A tester class does not contain the main method. C) You do not have to display the expected results. D) Writing test programs is not an important skill.
A) Test programs verify that methods have been implemented correctly.
Which statement stores an integer value in a variable? A) count = 5; B) String count = 5; C) int count; D) integer count = 5;
A) count = 5;
Assume that the variable count has been declared as type int, which statement changes the value of count? A) count = 6; B) count == 6; C) integer count = 6; D) count := 6;
A) count = 6;
What is the name of the type that denotes floating-point numbers that can have fractional parts? A) double B) floatingPoint C) int D) integer
A) double
Which of the following is the best choice for a variable identifier that will store a name? A) name B) Name C) n D) nm
A) name
Which operator constructs object instances? A) new B) instanceof C) void D) construct
A) new
A _____________ is a collection of classes with a related purpose. A) package B) import C) method D) collection
A) package
An ______ decision is a decision in which two conditions must be true for an action to take place.
AND
Most programming languages allow you to ask two or more questions in a single comparison by using an __________ operator that joins decisions in a single statement.
AND
When you combine AND and OR operators, the ______ operators take precedence, meaning their Boolean values are evaluated first.
AND
____ is the process of paying attention to important properties while ignoring nonessential details.
Abstraction
Adding a main Method
Adding a main method to the class • Conventionally placed at the end of the class code, after all the other methods • What are the advantages of having the test harness (main method) right in the class, rather than creating another class that is just a test program?
git add
Adds files changes in your working directory to your index. Example: git add .
D
After a programmer plans the logic of a program, the next step is ____. a. understanding the problem b. testing the program c. translating the program d. coding the program
C
After programs are put into production, making necessary changes is called _____. a. debugging b. conversion c. maintenance d. testing
F
Alan Turing is often regarded as the first programmer.
All format specifiers begin with%, explain:
All format specifiers begin with %, thus % is a special character. To print a % character using printf(), the sequence %% is used, as in: printf("Annual percentage rate is %f %%.\n", rate);.
What is the name of the = operator in Java? A) inequality B) assignment C) identity D) equality
B) assignment
untracked files
Any files in your working directory that were not in your last snapshot and are not in your staging area
bitwise operator
Anything and everything in the computer's memory is stored as a bit represented by 1s and 0s. So, the machine language of a computer is 1 and 0. It's that simple & Exclusive AND ^ Exclusive OR | Inclusive OR
Which one of the following types of statements is an instruction to replace the existing value of a variable with another value?
Assignment
d
Assuming that the user enters 45 and 62 as inputs for n1 and n2, respectively, what is the output of the following code snippet? public static void main(String[] args) { System.out.print("Enter a number: "); Scanner in = new Scanner(System.in); String n1 = in.next(); System.out.print("Enter another number: "); String n2 = in.next(); String result = n1 + n2; System.out.print(result); } a) 46 b) 4662 c) 107 d) 4562
Run a debug configuration that has already been created on the selected Java project
At the top of the eclipse IDE menu bar-Click on the RUN - Debug. Alternatively on the top right-hand corner of the eclipse IDE menu bar - Press the Debug Button
I want to find the last edited location. How can I do this in the eclipse IDE?
At the top of the eclipse IDE menu bar-click NAVIGATE then click LAST EDIT LOCATION (CTRL+Q)
I want to locate all files in my workspace. How do I do this in the eclipse IDE?
At the top of the eclipse IDE menu bar-click NAVIGATE then click OPEN RESOURCE then type "?" and you will get a list of ALL of the FILES within your workspace. You can also enter the name of the file to search within your workspace.
I want to find more information on the class Vector API type. How can I do this in eclipse?
At the top of the eclipse IDE menu bar-click NAVIGATE then click OPEN TYPE then type Vector and you will get an overview of the Javadoc on the Vector class
What terminology describes a method that returns information about its implicit parameter and does not change the parameter's internal data? A) mutator B) accessor C) void D) public
B) accessor
Which of the following statements about classes is correct? A) By convention, class names begin with a lowercase letter. B) A class declares the methods that you can apply to its objects. C) All entities, even primitive numbers, are classes. D) A class is a sequence of instructions that accesses the data of an object.
B) A class declares the methods that you can apply to its objects.
Which statement declares a variable that references a Circle of radius 3? A) Circle c = Circle(3) B) Circle c = new Circle(3); C) Circle c.new.Circle(3); D) c.Circle(3);
B) Circle c = new Circle(3);
Which of the following statements about objects is correct? A) An object defines the methods for a class. B) Every object belongs to a class. C) An object is a sequence of instructions. D) All entities, even numbers, are objects.
B) Every object belongs to a class.
Which of the following represents a method call to a method with a void return type? A) greeting.isEmpty() B) System.out.println() C) greeting.replace("Hello","World") D) greeting.length()
B) System.out.println()
Which of the following statements about methods is correct? A) A method can have only one explicit parameter. B) The return value of a method can be used as a parameter. C) Every method must have a return value. D) A method can have multiple implicit parameters.
B) The return value of a method can be used as a parameter.
Operator
Basic building blocks of programming statements.
A
Before a programmer plans the logic of the program, he or she must ____. a. understand the problem b. write the program code c. test the program d. maintain the program
T
Besides the popular, comprehensive programming languages such as Java and C++, many programmers use scripting languages such as Python, Lua, Perl, and PHP.
A selection with an action that is associated with each of two possible outcomes is known as a(n) _____ selection.
Binary
______ operators require two operands.
Binary
Logical Operators
Binary operators that compare the results of two expressions. The result is either true or false.
Relational Operators
Binary operators that compare two operands, or two values, with each other, resulting in a true or false.
Inside your Java source code of the eclipse IDE-you want to automate the creation of code blocks e.g. generic while loop-how do you do this?
CONTENT ASSIST-Press CTRL+SAPCEBAR -this will bring up a number of suggestions in terms of automatically creating a new method or while loop block etc.
git checkout
Checks out a different branch - switches branches by updating the index, working tree, and HEAD to reflect the chosen branch. Example: git checkout newbranch
git commit
Committing Your Changes (Remember that the commit records the snapshot you set up in your staging area. Every time you perform a commit, you're recording a snapshot of your project that you can revert to or compare to later.)
What is the output of the following statement sequence? public static void main(String[] args) { int x = 100.0 % 6.0; System.out.println(x); }
Compile-time error
Dummy
Complete The Statement. A preselected value that stops the execution of a program is often called a(n) ____________________ value because it does not represent real data.
Algorithm
Complete The Statement. A(n) ____________________ is the sequence of steps necessary to solve any problem.
Graphical User Interface
Complete The Statement. GUI stands for ________________ _______________ __________________ .
Integrated Development Environment
Complete The Statement. IDE stands for ______________ _______________ _______________ .
Kemeny Kurtz
Complete The Statement. The BASIC programming language was created by Drs. _____________ and ___________.
Executes
Complete The Statement. When instructions are carried out, a program runs, or ____________________.
Parallelogram
Complete The Statement. When you draw a flowchart, you use a(n) ____________________ to represent the input symbol, which indicates an input operation.
Class Object
Complete The Statement. blueprint/model : house(s) :: _____________ : ________________
Using a class object within another class object is known as _______
Composition
When you ask multiple questions before an outcome is determined, you create a _______ condition.
Compound
D
Computer programmers often refer to memory addresses using ____ notation. a. binary b. indirect c. mathematical d. hexadecimal
b
Consider the following division statements: I. 22 / 7 II. 22.0 / 7 III. 22 / 7.0 Which of the following is correct? a) All three statements will return an integer value. b) Only I will return an integer value. c) Only I, II will return an integer value. d) Only I and III will return an integer value.
List and describe three characteristics that all files have in common.
Each file has a name. The name often includes a dot and a filename extension, which is a group of characters added to the end of a filename that describes the type of file. For example, .txt is a plain text file, .dat is a data file, and .jpg is an image file in Joint Photographic Experts Group format. A filename's extension frequently designates the software that will be used to open a file; for example, a file that uses the extension .docx will usually be opened by Microsoft Word by default. Each file has a specific time of creation and a time it was last modified. Each file occupies space on a section of a storage device; that is, each file has a size. Sizes are measured in bytes.
The act of repeating input back to a user either in a subsequent prompt or in output
Echoing input
To enter the program into a computer so you can translate and execute it, you usually use a keyboard to type program statements into a(n)____.
Editor
Complete the following statement, which constructs an ellipse. Ellipse2D.Double ellipse = new ____________________ (x, y, width, height);
Ellipse2D.Double
The keyword that is NOT included in a single-alternative selection is ________.
Else
Programmers say the statements that are contained in a module have been ____.
Encapsulated
1. The ability to use methods without knowing the details of their contents is a feature of _______.
Encapsulation
What is the output of: import java.util.Scanner; public class FlyDrive { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); double miles; // User defined distance double hrsFly; // Time to fly distance double hrsDrive; // Time to drive distance // Prompt user for distance System.out.print("Enter a distance in miles: "); miles = scnr.nextDouble(); // Calculate the correspond time to fly/drive distance hrsFly = miles / 500.0; hrsDrive = miles / 60.0; // Output resulting values System.out.printf("%.2f miles would take:\n", miles); System.out.printf("%.2f hours to fly\n", hrsFly); System.out.printf("%.2f hours to drive\n", hrsDrive); } }
Enter a distance in miles: 10.3 10.30 miles would take: 0.02 hours to fly 0.17 hours to drive
Rewrite the following code as a series of equivalent System.out.println statements (i.e., without any System.out.print statements): System.out.print("Twas "); System.out.print("brillig and the "); System.out.println(" "); System.out.print(" slithy toves did"); System.out.print(" "); System.out.println("gyre and"); System.out.println( "gimble"); System.out.println(); System.out.println( "in the wabe." );
Equivalent code without System.out.print statements: System.out.println("Twas brillig and the "); System.out.println(" slithy toves did gyre and"); System.out.println("gimble"); System.out.println(); System.out.println("in the wabe.");
Which of the following statements about objects is correct?
Every object belongs to a class.
T
Every programming language has rules governing its word usage and punctuation.
Floating point values is done how?
Floating point values: Formatting floating-point output is commonly done using the following sub-specifiers options. For the following assume myFloat has a value of 12.34. Recall that %f is used for floating-point values and %e is used to display floating-point values in scientific notation.
git diff
Generates patch files or statistics of differences between paths or files in your git repository, or your index or your working directory. Example: git diff
What does the following statement sequence print? String str = "Java Is Good"; int n = str.length(); String mystery = str.substring(n - 4, n) + str.charAt(4) + str.substring(0, 4); System.out.println(mystery);
Good Java
____ is where a variable's data type or other information is stored as part of the name.
Hungarian notation
A(n) ____ is a software package that provides an editor, a compiler, and other programming tools.
IDE
A program component's name
Identifier
Which statement about identifiers is correct?
Identifiers can be made up of letters, digits, and the underscore (_) character.
Which statement about number literals in Java is false?
Integers must be positive
Which one of the following refers to a number constant that appears in code without explanation?
Magic number
Create a new Java project
In the top of the eclipse IDE menu bar- click FILE - NEW - JAVA PROJECT
24. What precaution can save you from a losing files corrupted by a virus infecting your computer?
Make regular backups of all your important files.
Logic errors can be caused by:
Incorrect algorithms. These errors are the most difficult to fix. It is very important that you spend sufficient time designing your algorithms and making sure they are correct before you implement them in Java.
git init
Initializes a git repository - creates the initial '.git' directory in a new or in an existing project. Example: cd /home/user/my_new_git_folder/ git init
Parallelogram
Input, Output
Using print statements
Insert *System.out.println()* statements at key locations: • to show values of significant variables • to show how far your code got before there was a problem In the print statement, it's a good idea to specify • The location of the trace (what method) • The variable name as well as its value
I wish to rename a class safely . How can I do this in eclipse IDE?
Inside the JAVA SOURCE CODE EDITOR - double-click on the CLASS NAME then RIGHT-CLICK then press REFACTOR then press RENAME i.e. not only will the class change name but also ALL of its OBJECT INSTANCES will change safelyto the new name.
I wish to make an interface from a concrete class implementation. How do I do this in eclipse IDE?
Inside the JAVA SOURCE CODE EDITOR- double-click on the CLASS NAME that you wish to extract an interface then RIGHT-CLICK then press REFACTOR then press EXTRACT INTERFACE - NAME the interface then TICK the methods to declare within the interface
Automatically create a getter and setter method for an instance variable
Inside the editor pane LEFT CLICK on the MARKER BAR LIGHT BULB ICON to the left of the instance variable line then choose CREATE GETTER AND SETTER FOR VARNAME
Type a for loop in your code using the auto complete/code template
Inside your eclipse Java source code editor -type the letter f and then press CTRL+SPACEBAR. You will then review a number of options and choose the "for iterate array" option
The data components of a class that belong to every instantiated object are the class's _______ variables
Instance
23. What does a class file contain?
Instructions for the Java Virtual Machine.
reasonable methods of testing code
JUnit, setting breakpoints, printing to the console
21. The statement that is true about a Java program.
Java is case sensitive.
Assuming that the user inputs "Joe" at the prompt, what is the output of the following code snippet? public static void main(String[] args) { System.out.print("Enter your name "); String name; Scanner in = new Scanner(System.in); name = in.next(); name += ", Good morning"; System.out.print(name); }
Joe, Good morning
git grep
Lets you search through your trees of content for words and phrases. Example: git grep "www.siteground.com" -- *.php
How is printf() different from println() and print()?
Like the print() and println() methods, printf() allows a programmer to print text along with variable values. printf(), however, affords the programmer more freedom in specifying the format of the output.
What menu item can enable you to copy and paste?
Located at the top of the eclipse IDE menu bar- the EDIT menu presents items like copy & paste.
Located on the bottom of the eclipse IDE Eclipse, to move a view from one view folder to another just ______ on the view ______ and ____to the title bar area of another view folder.
Located on the bottom of the eclipse IDE Eclipse, to move a view from one view folder to another just CLICK on the view TITLE and DRAG to the title bar area of another view folder.
Add existing jars to the java build path.
Located on the left-hand side of the eclipse IDE- Inside PROJECT EXPLORER - Right Click PROJECT NAME and click PROPERTIES - JAVA BUILD PATH - LIBRARIES TAB - ADD JARS
Located on the top of the eclipse IDE in the _____ menu allows you to open files for editing, close editors, save editor content and rename files. Among the other things, it also allows you to import and export workspace content and shutdown Eclipse.
Located on the top of the eclipse IDE in the FILE menu allows you to OPEN files for editing, CLOSE editors, SAVE editor content and rename files. Among the other things, it also allows you to IMPORT and EXPORT WORKSPACE content and SHUTDOWN Eclipse.
Located on the top of the eclipse IDE in the ________ menu allows you to quickly locate resources and navivate to them.
Located on the top of the eclipse IDE in the MENU bar - The NAVIGATE menu allows you to quickly LOCATE RESOURCES and navigate to them e.g. click inside Java Code then click on Navigate menu - OPEN CALL HIERARCHY
Located on the top of the eclipse IDE in the______ menu is visible only when a java editor is open. It presents a number of useful menu items related to editing java source code.
Located on the top of the eclipse IDE in the SOURCE menu is visible only when a java editor is open and ACTIVE. It presents a number of useful menu items related to editing java source code.
Open a view by clicking on the ________ menu select the _________ ____ menu item.
Located on the top of the eclipse IDE menu - open a view by clicking on the WINDOW menu then select the SHOW VIEW menu item. e.g. Package Explorer or Palette or Navigator etc.
Which one of the following refers to a number constant that appears in code without explanation?
Magic Number
In your own words, describe an algorithm for baking cookies. Assume that you have a large number of hungry friends, so you'll want to produce several batches of cookies!
Make the cookie batter: Mix the dry ingredients. Cream the butter and sugar. Beat in the eggs. Stir in the dry ingredients. Bake the cookies: Set the oven for the appropriate temperature. Set the timer. Place the cookies into the oven. Allow the cookies to bake. Add frosting and sprinkles: Mix the ingredients for the frosting. Spread frosting and sprinkles onto the cookies.
C
Match The Term With The Def. Many programming languages use the term ____ to refer to the marker that is used to automatically recognize the end of data in a file. a. data_end b. end_data c. eof d. eod
B
Match The Term With the Def. a. volatile memory b. software c. syntax error d. machine e. sentinel f. pseudocode. g. hardware h. flowchart language i. flowlines j. documentation Instructions that tell the computer what to do
H
Match The Term With the Def. a. volatile memory b. software c. syntax error d. machine e. sentinel f. pseudocode. g. hardware h. flowchart language i. flowlines j. documentation Pictorial representation of the logical steps it takes to solve a problem
E
Match The Term With the Def. a. volatile memory b. software c. syntax error d. machine e. sentinel f. pseudocode. g. hardware h. flowchart language i. flowlines j. documentation Preselected value that stops the execution of a program
D
Match The Term With the Def. a. volatile memory b. software c. syntax error d. machine e. sentinel f. pseudocode. g. hardware h. flowchart language i. flowlines j. documentation Represent(s) the millions of on/off circuits within the computer
I
Match The Term With the Def. a. volatile memory b. software c. syntax error d. machine e. sentinel f. pseudocode. g. hardware h. flowchart language i. flowlines j. documentation Used to show the correct sequence of statements
The following program contains at least 10 errors. Correct the errors and submit a working version of the program. public class LotsOf Errors { public static main(String args) { System.println(Hello, world!); message() } public static void message { System.out println("This program surely cannot "; System.out.println("have any "errors" in it"); }
Mistakes in LotsOfErrors program: line 1: The class name should be LotsOfErrors (no space). line 2: The word void should appear after static. line 2: String should be String[]. line 3: System.println should be System.out.println. line 3: "Hello, world!) should be "Hello, world!"). line 4: There should be a semicolon after message(). line 7: There should be a () after message. line 8: System.out println should be System.out.println. line 8: cannot"; should be cannot");. line 9: The phrase "errors" cannot appear inside a String. 'errors' or \"errors\" would work. line 11: There should be a closing } brace.
The following program contains three errors. Correct the errors and submit a working version of the program. public MyProgram { public static void main(String[] args) { System.out.println("This is a test of the") System.out.Println("emergency broadcast system."); } }
Mistakes in MyProgram program: line 1: The keyword class is missing. line 3: A semicolon is missing. line 4: The word Println should not be capitalized.
The following program contains three errors. Correct the errors and submit a working version of the program. public class SecretMessage { public static main(string[] args) { System.out.println("Speak friend"); System.out.println("and enter); }
Mistakes in SecretMessage program: line 2: The keyword void is missing. line 2: The word string should be capitalized. line 4: A closing " mark is missing. line 5: A closing } brace is missing.
Case
Most languages allow you to use a variation of the decision structure called the ____ structure when you must nest a series of decisions about a single variable.
AND
Most programming languages allow you to ask two or more questions in a single comparison by using a(n) ____ operator that joins decisions in a single statement.
A specific numeric value is often called a
Numeric Constant
Can hold digits and have mathematical operations performed on it.
Numeric Variable
Can hold digits and have mathematical operations performed on it
Numeric variable
An ______ decision is a decision in which at least one of two conditions must be true for an action to take place.
OR
how can you change the shortcut keys in eclipse?
On the top of the eclipse IDE menu bar click WINDOW - PREFERENCES on the left-hand side click GENERAL-KEYS then click on one of the shortcuts and change the shortcut accordingly in the BINDING
Create a debug configuration for a Java application
On the top of the eclipse IDE menu bar- Click on RUN - DEBUG CONFIGURATIONS - Then on the left-hand side right-click the JAVA APPLICATION and press the NEW BUTTON to create a new debug configuration you can also create a new J unit Debug Configuration -
How can you invoke the Debug Configuration dialog for a Java project?
On the top of the eclipse IDE menu bar- the Debug Configuration dialog can be invoked by selecting the DEBUG CONFIGURATIONS menu item from the RUN menu.
Show the Run configuration of a Java project
On the top of the eclipse IDE- Click Run - Run Configurations
Share a project folder in Eclipse
On the top of the eclipse IDE- In the Run Configurations the COMMON tab provides common options such as the ability to share your project folder.
Run in debug mode to line 9 and step through on the Java class
On the top right-hand corner of the eclipse IDE-click on the DEBUG PERSPECTIVE- Inside the Java application editor-right-click on the MARKER BAR and select a TOGGLE BREAKPOINT on line 9 - on the top of the eclipse IDE - Click DEBUG TEST and then PRESS STEP INTO
Consider the following division statements: I. 22 / 7 II. 22.0 / 7 III. 22 / 7.0 Which of the following is correct?
Only I will return an integer value.
Consider the following Java variable names: I. 1stInstance II. basicInt% III. empName_ IV. addressLine1 V. DISCOUNT Which of the following options is correct?
Only III, IV, and V are valid Java variable names.
What is the output of the following program? Note that the program contains several comments. public class Commentary { public static void main(String[] args) { System.out.println("some lines of code"); System.out.println("have // characters on them"); System.out.println("which means "); // that they are comments // System.out.println("written by the programmer."); System.out.println("lines can also"); System.out.println("have / and "); System.out.println(/ characters"); /* "which represents" System.out.println("a multi-line style"); */ System.out.println("of comment."); } }
Output of Commentary program: some lines of code have // characters on them which means lines can also have / and / characters of comment.
What is the output from the following Java program? public class Confusing { public static void method1() { System.out.println("I am method 1."); } public static void method2() { method1(); System.out.println("I am method 2."); } public static void method3() { method2(); System.out.println("I am method 3."); method1(); } public static void main(String[] args) { method1(); method3(); method2(); method3(); } }
Output of Confusing program: I am method 1. I am method 1. I am method 2. I am method 3. I am method 1. I am method 1. I am method 2. I am method 1. I am method 2. I am method 3. I am method 1.
What is the output produced from the following program? You may wish to draw a structure diagram first. This is a slightly modified version of the previous problem, Confusing. public class Confusing { public static void main(String[] args) { method1(); method3(); method2(); method3(); } public static void method2() { method1(); System.out.println("I am method 2."); } public static void method3() { method1(); method2(); System.out.println("I am method 3."); } public static void method1() { System.out.println("I am method 1."); } }
Output of Confusing2 program: I am method 1. I am method 1. I am method 1. I am method 2. I am method 3. I am method 1. I am method 2. I am method 1. I am method 1. I am method 2. I am method 3.
What is the output produced from the following program? You may wish to draw a structure diagram first. This is a slightly modified version of the previous problem, Confusing2. public class Confusing { public static void main(String[] args) { method2(); method1(); method3(); method2(); } public static void method2() { method1(); System.out.println("I am method 2."); } public static void method3() { method2(); System.out.println("I am method 3."); method1(); } public static void method1() { System.out.println("I am method 1."); } }
Output of Confusing3 program: I am method 1. I am method 2. I am method 1. I am method 1. I am method 2. I am method 3. I am method 1. I am method 1. I am method 2.
What is the output produced from the following program? You may wish to draw a structure diagram first. public class Strange { public static void main(String[] args) { first(); third(); second(); third(); } public static void first() { System.out.println("Inside first method."); } public static void second() { System.out.println("Inside second method."); first(); } public static void third() { System.out.println("Inside third method."); first(); second(); } }
Output of Strange program: Inside first method Inside third method Inside first method Inside second method Inside first method Inside second method Inside first method Inside third method Inside first method Inside second method Inside first method
What is the output produced from the following program? You may wish to draw a structure diagram first. This is a slightly modified version of the previous problem, Strange. public class Strange { public static void main(String[] args) { second(); first(); second(); third(); } public static void first() { System.out.println("Inside first method."); } public static void second() { System.out.println("Inside second method."); first(); } public static void third() { System.out.println("Inside third method."); first(); second(); } }
Output of Strange2 program: Inside first method Inside first method Inside second method Inside first method Inside third method Inside second method Inside first method Inside first method Inside second method Inside first method Inside third method
What is the output produced from the following program? You may wish to draw a structure diagram first public class Tricky { public static void main(String[] args) { message1(); message2(); System.out.println("Done with main."); } public static void message1() { System.out.println("This is message1."); } public static void message2() { System.out.println("This is message2."); message1(); System.out.println("Done with message2."); } }
Output of Tricky program: This is message1. This is message2. This is message1. Done with message2. Done with main.
What is the output produced from the following statements? (Treat tabs as aligning to every multiple of eight spaces.) - System.out.println("\ta\tb\tc"); - System.out.println("\\\\"); - System.out.println("'"); - System.out.println("\"\"\""); - System.out.println("C:\nin\the downward spiral");
Output of statements: a b c \\ ' """ C: in he downward spiral
What is the output from the following Java program? (Assume that a tab is expanded into eight spaces.) public class Letter { public static void main(String[] args) { System.out.println("Dear \"DoubleSlash\" magazine,"); System.out.println(); System.out.println("\tYour publication confuses me. Is it"); System.out.println("a \\\\ slash or a //// slash?"); System.out.println("\nSincerely,"); System.out.println("Susan \"Suzy\" Smith"); } }
Output of statements: Dear "DoubleSlash" magazine, Your publication confuses me. Is it a \\ slash or a //// slash? Sincerely, Susan "Suzy" Smith
T
Programmers can use either procedural programming or object-oriented programming to develop programs.
A message that is displayed on a monitor to ask the user for a response and perhaps explain how that response should be formatted
Prompt
A message that is displayed on a monitor to ask the user for a response and perhaps explain how that response should be formatted.
Prompt
git instaweb
Runs a web server with an interface into your local repository and automatically directs a web browser to it.
The following program is legal under Java's syntax rules, but it is difficult to read because of its layout and lack of comments. Reformat it using the rules given in Chapter 1, and add a comment header at the top of the program. (Practice-It isn't really able to check that you satisfied the requirements of this question. You will receive credit as long as you supply a reasonable amount of indentation and add two lines of // comments.) public class GiveAdvice{ public static void main (String[ ]args){ System.out.println ( "Programs can be easy or"); System.out.println( "difficult to read, depending" ); System.out.println("upon their format.") ;System.out.println();System.out.println( "Everyone, including yourself,"); System.out.println ("will be happier if you choose"); System.out.println("to format your programs." ); } }
Reformatted version of GiveAdvice program: // Suzy Student, Fall 2048 // This program prints a message about proper formatting // of Java programs. public class GiveAdvice { public static void main(String[] args) { System.out.println("Programs can be easy or"); System.out.println("difficult to read, depending"); System.out.println("upon their format."); System.out.println(); System.out.println("Everyone, including yourself,"); System.out.println("will be happier if you choose"); System.out.println("to format your programs."); } }
git rm
Removes files from your index and your working directory so they will not be tracked. Example: git rm filename
git prune
Removes objects that are no longer pointed to by any object in any reachable branch. Example: git prune
git reset
Resets your index and working directory to the state of your last commit. Example: git reset --hard HEAD
The concept of a class is useful because of its ______
Reusability
What does the following statement sequence print? String str = "Hello"; int n = str.length(); String mystery = str.substring(0, 1) + str.substring(n - 2, n + 1); System.out.println(mystery);
Run-time error
2. ...
Select Run->Debug as...->Java Application to start the debugger. If asked, accept to switch to debug Perspective.
Preselected value that stops the execution of a program
Sentinel
git config
Sets configuration values for your user name, email, gpg key, preferred diff algorithm, file formats and more. Example: git config --global user.name "My Name" git config --global user.email "[email protected]" cat ~/.gitconfig [user] name = My Name email = [email protected]
______ evaluation is when each part of an expression that uses an operator is evaluated only as far as necessary to determined whether the entire expressions is true or false.
Short-circuit
git log
Shows a listing of commits on a branch including the corresponding details. Example: git log commit 84f241e8a0d768fb37ff7ad40e294b61a99a0abe Author: User <[email protected]> Date: Mon May 3 09:24:05 2010 +0300 first commit
git ls-tree
Shows a tree object, including the mode and the name of each item and the SHA-1 value of the blob or the tree that it points to. Example: git ls-tree master^{tree} 100644 blob e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 README
git remote
Shows all the remote versions of your repository. Example: git remote origin
16. What is the object in the given method call? System.out.println("Welcome");
System.out
If greeting refers to a String object, which of the following is a syntactically correct Java statement?
System.out.println(greeting.length());
Which of the following method calls illustrate using the return value of a method as an argument?
System.out.println(greeting.length());
Which of the following is the correct syntax to output a message? - System.println.out('Hello, world!'); - Out.system.println"(Hello, world!)"; - System.out.println("Hello, world!"); - System.println(Hello, world!); - System.println("Hello, world!");
System.println(Hello, world!);
The Java build path is used while compiling a Java project to discover dependent classes . It is made up of the #1 Code in the _______folders -#2 ______ and _____folder associated with the project #3 _____and _____exported by projects referenced by this project
The Java build path is used while compiling a Java project to discover dependent classes . It is made up of the #1 Code in the SOURCE folders #2 JARS and CLASSES folder associated with the project #3 CLASSES and LIBRARIES exported by projects referenced by this project
Located in the left-hand side of the eclipse IDE - the______ _______ shows the newly created Java project.
The PACKAGE EXPLORER shows the newly created Java project.
XOR (exclusively OR)
The binary Boolean operation that results in true if only one of the two operands is true, with the other being false.
OR
The binary operation in Boolean logic that results in a true value if either or both operands are true.
What is wrong with the following code snippet? public class Area { public static void main(String[] args) { int width = 10; height = 20.00; System.out.println("area = " + (width * height)); }
The code snippet uses an undeclared variable.
git commit - a
The command makes Git automatically stage every file that is already tracked before doing the commit (you don't have to run git add before you commit).
The default perspective is called _____.
The default perspective is called JAVA. On the top RIGHT-HAND corner of eclipse you can change to JAVA PERSPECTIVE or DEBUG PERSPECTIVE or JAVA BROWSING PERSPECTIVE etc
A string variable can hold digits such as account numbers and zip codes.
True
The eclipse _______ folder contains resources such as: Projects - ______ - Folders
The eclipse WORKSPACE contains resources such as: Projects, FILES, Folders e.g. C:\Users\mark.burleigh\workspace
What are format specifiers?
The first argument of the printf() method is referred to as the format string, which specifies the format of the text that will be printed along with any number of placeholders for printing numeric values. These placeholders are known as format specifiers. Format specifiers specify the type of values being printed in place of the format specifier.
what can format specifiers within the format string of printf() include? Explain:
The format specifiers within the format string of printf() can include format sub-specifiers. These sub-specifiers specify how a value stored within a variable will be printed in place of a format specifier.
Else
The keyword that is NOT included in a single-alternative selection is ____.
Which of the following can be used in a Java program as identifiers? Check all of the identifiers that are legal. sum_of_data "hello" _average B4 first-name 42isThesolution for ABC AnnualSalary Println
The legal identifiers shown are println, AnnualSalary, ABC, sum_of_data, _average, B4.
C
The major difference between the two main programming styles in use today is the ____. a. use of flowcharts versus pseudocode b. testing procedure used by the programmer c. programmer's focus during the earliest planning stages of a project d. programming language used
git log --pretty=format:"%h"
The most interesting option is option, which allows you to specify your own log output format.
Assuming that the user inputs a value of 25000 for the pay and 10 for the bonus rate in the following code snippet, what is the output? public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter the pay: "); double pay = in.nextDouble(); System.out.print("Enter the bonus rate: "); double bonus = in.nextDouble(); System.out.println("The new pay is " + (pay + pay * (bonus / 100.0))); }
The new pay is 27500
Assuming that the user inputs a value of 25 for the price and 10 for the discount rate in the following code snippet, what is the output? public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter the price: "); double price = in.nextDouble(); System.out.print("Enter the discount rate: "); double discount = in.nextDouble(); System.out.println("The new price is " + price - price * (discount / 100.0)); }
The new price is 22.5
Assuming that the user inputs a value of 30 for the price and 10 for the discount rate in the following code snippet, what is the output? Scanner in = new Scanner(System.in); System.out.print("Enter the price: "); double price = in.nextDouble(); System.out.print("Enter the discount rate: "); double discount = in.nextDouble(); System.out.print("The new price is "); System.out.println(price - price * (discount / 100.0));
The new price is 27.0
Located on the left-hand side of the eclipse IDE - The newly created class should appear in the ______ ______ view and a java editor instance that allows you to modify the new class should appear in the editor area.
The newly created class should appear in the PACKAGE EXPLORER view and a java editor instance that allows you to modify the new class should appear in the editor area.
NOT
The operation Boolean logic that indicates negation, or "opposite of" operator. A symbol used in mathematical and logical expressions, such as the plus (+) or division (/) sign.
git log -p
The options which shows the difference introduced in each commit
Order of Operations
The order of precedence of all of the operators in a computational system, such as mathematics (PEMDAS) or logic (NAXO)
What is wrong with the following code snippet? int price; price = 9.42;
The price variable is assigned a decimal value.
Concatenation
The process of connecting or joining two strings of characters into a larger string of characters, an operation often indicated by the plus (+) sign.
D
The process of finding and correcting program errors is called ____. a. desk-checking b. syntax-checking c. error correcting d. debugging
A
The process of walking through a program's logic on paper before you actually write the program is called ____. a. desk-checking b. flowcharting c. pseudocoding d. testing
What's the quickest way to debug a Java program?
The quickest way to debug a Java program is to using the PACKAGE EXPLORER view. RIGHT-CLICK on the java CLASS that contains the MAIN method Select DEBUG AS> Java APPLICATION
Which of the following statements about methods is correct?
The return value of a method can be used as an argument to another method
The standard output stream System.out provides what?
The standard output stream System.out provides the methods printf() and format() for this task. Both methods are equivalent, so this discussion will only refer to printf().
What is the result of the following statement? String s = "You" + "had" + "me" + "at" + "hello";
The string s has the following value: "Youhadmeathello"
What is the purpose of a test program?
The test program verifies that methods have been implemented correctly.
Which of the following options is valid with reference to the code snippet? public static void main(String[] args) { double d = 45.326; double r = d % 9.0; System.out.println(r); }
The value inside the variable r will be 0.326
A short-circuit evaluation is where each part of an expression is evaluated only as far as necessary to determine whether the entire expression is true or false. (T/F)
True
git diff --staged
This command compares your staged changes to your last commit
git tag
This command lists the tags in alphabetical order
git remote -v
This command shows you the URLs that Git has stored for the shortname to be used when reading and writing to that remote
git init
This creates a new subdirectory named .git that contains all of your necessary repository files.
br
This is custom added to the .gitconfig file in the HOME directory branch
dump
This is custom added to the .gitconfig file in the HOME directory. cat-file -p
type
This is custom added to the .gitconfig file in the HOME directory. cat-file -t
co
This is custom added to the .gitconfig file in the HOME directory. checkout
ci
This is custom added to the .gitconfig file in the HOME directory. commit
st
This is custom added to the .gitconfig file in the HOME directory. status
git log --graph
This option adds a nice little ASCII graph showing your branch and merge history
git log --pretty
This option changes the log output to formats other than the default.
git log --pretty=oneline
This option prints each commit on a single line. n addition, the 'short', 'full', and 'fuller' options show the output in roughly the same format but with less or more information.
git push origin --tags
This will transfer all of your tags to the remote server that are not already there.
git remote add [shortname] [url]
To add a new remote Git repository as a shortname you can reference easily
To close a perspective-in the top right-hand corner of the eclipse IDE- _____ _____on the perspective and select the Close menu item.
To close a perspective, RIGHT-CLICK on the perspective NAME in TOOLBAR and select the Close menu item.
git tag v1.4-lw
To create a lightweight tag, don't supply the -a, -s, or -m option
git remote
To see which remote servers you have configured
Set a breakpoint in the selected Java class
To set a break point, in the EDITOR AREA RIGHT-CLICK on the MARKER BAR and select TOGGLE BREAKPOINT.
A class can contain another class's objects as data members.
True
String
Usually, ____ variables are not considered to be equal unless they are identical.
What is the output of the following code snippet? public static void main(String[] args){ { String str1; str1 = "I LOVE MY COUNTRY"; String str2 = str1.substring(4, 9); System.out.println(str2); }
VE MY
A ______ is an environment in which you can create programs by dragging components such as buttons and labels onto a screen and arranging them visually
Visual development environment
Contents are lost when the computer is turned off or loses power
Volatile memory
b
What is the output of the following statement sequence? public static void main(String[] args) { int x = 100.0 % 6.0; System.out.println(x); } a) 4 b) Compile-time error c) Run-time error d) 16
a
What is the output of this code snippet? double average; int grade1 = 87; int grade2 = 94; // System.out.print("The average is " + (grade1 + grade2) / 2.0); System.out.print("The average is " + average); a) Unpredictable result b) The average is 91.5 c) The average is 91.5 The average is 91.5 d) The average is 91.5 The average is 0.0
-2 (how???)
What is the value inside the value variable at the end of the given code snippet? public static void main(String[] args) { int value = 3; value = value - 2 * value; value++; }
b
What is wrong with the following code snippet? int size = 42; cost = 9.99; System.out.println("size = " + size); System.out.println(" cost = " + cost); a) The code snippet uses a variable that has not yet been initialized. b) The code snippet uses a variable that has not been declared. c) The code snippet attempts to assign a decimal value to an integer variable. d) The code snippet attempts to assign an integer value to a decimal variable.
The code snippet uses an undeclared variable.
What is wrong with the following code snippet? public class Area { public static void main(String[] args) { int width = 10; height = 20.00; System.out.println("area = " + (width * height)); } }
Four
When creating a truth table, you must determine how many possible Boolean value combinations exist for the conditions. If there are two conditions, ____ combinations will exist.
All your data will be stored in the _______folder.
When eclipse starts up for the first time it prompts you for the location of the WORKSPACE folder e.g.C:\Users\mark.burleigh\workspace
When the execution of code reaches a break point the JVM __________the execution of the program.
When the execution of code reaches a break point the JVM SUSPENDS the execution of the program.
Hints for Success
When writing code • Make sure your algorithm is correct before you start coding. • Start small: - Write and test first simpler methods (e.g. getters, setters, toString) • Then write and test each of the more complex methods individually Check your code first by a preliminary hand trace Then try running it
Compound
When you ask multiple questions before an outcome is determined, you create a ____ condition.
Defensive Programming
Write *robust programs* • Include checking for exceptional conditions; try to think of situations that might reasonably happen, and check for them - Examples: files that don't exist, bad input data • Generate appropriate error messages, and either allow the user to reenter the data or exit from the program Throw exceptions (we will cover this topoc later)
c
Which of the following statements about constants in Java are true? I. Although not required, constants are commonly named using uppercase letters II. Only integer values can appear as constants III. A variable can be defined with an initial value, but the reserved word final prevents it from being changed IV. A named constant makes computations that use it clearer a) I, II, III b) II, III, IV c) I, III, IV d) I, II, IV
c
Which of the following statements is correct about constants? a) Constants are written using capital letters because the compiler ignores constants declared in small letters. b) The data stored inside a constant can be changed using an assignment statement. c) You can make a variable constant by using the final reserved word when declaring it. d) Constant variables can only be changed through the Math library.
a
Which of the given System.out.print statements generates the following output? ABCDE"\ a) System.out.println("ABCDE\"\\"); b) System.out.println("ABCDE"\"); c) System.out.println("ABCDE"\); d) System.out.println("ABCDE\"\")
b (how???)
Which of the given statements generates the following output? \\\"/// a) System.out.println("\\\"///"); b) System.out.println("\\\\\\\"///"); c) System.out.println("\\\\\\""//////"); d) System.out.println("\\\"///");
d
Which of the methods below are static methods? I. length II. Substring III. Pow IV. sqrt a) All the methods are static b) Only I, II and III c) Only II and IV d) Only III and IV
b
Which one of the following is an assignment statement? a) int a = 20; b) a = 20; c) assign a = 20; d) assign 20 to a;
a
Which one of the following statements can be used to extract the last 10 characters from the string variable str? a) str.substring(str.length() - 10, str.length()) b) str.substring(10, str.length()) c) str.substring(str.length() - 9, 10) d) str.substring(0, 10)
a
Which one of the following statements can be used to extract the last five characters from any string variable str? a) str.substring(str.length() - 5, str.length()) b) str.substring(5, 5) c) str.substring(str.length() - 4, 5) d) str.substring(str.length() - 5, 5)
a
Which one of the following statements displays the output as (1.23e+02)? a) System.out.printf("%(5.2e", -123.0); b) System.out.printf("%5.2e", -123.0); c) System.out.printf("^5.2e", -123.0); d) System.out.printf("%5.2E", -123.0);
a
Which one of the following statements displays the output as +00321.00? a) System.out.printf("+%09.2f", 321.0); b) System.out.printf("%009,2f", 321.0); c) System.out.printf("+9.2f", 321.0); d) System.out.printf("%09.00f", 321.0);
a
Which one of the following statements displays the output as 54321.00? a) System.out.printf("%8.2f", 54321.0); b) System.out.printf("%8,2f", 54321.0); c) System.out.printf(",8.2f", 54321.0); d) System.out.printf("%8.00f", 54321.0);
b
Which one of the following statements gives the absolute value of the floating-point number x = -25.50? a) abs(x); b) Math.abs(x); c) x.abs(); d) x.absolute();
c
Which one of the following variables is assigned with valid literals? a) int salary = 0; salary = 5000.50; b) int salary1 = 0; salary1 = 1.2E6; c) double salary2 = 0; salary2 = 2.96E-2; d) long salary3 = 0; salary3 = 1E-6;
d
Which statement is true? a) Variables cannot be assigned and declared in the same statement b) Variable names must contain at least one dollar sign c) Variable names can be no more than 8 characters long d) It is incorrect to initialize a string variable with a number
b
Which statements about numeric types in Java are true? I. There is more than one integer type II. The data type float uses twice the storage of double III. The numeric range of the Java integer type is related to powers of two a) I, II b) I, III c) II, III d) I, II, III
Short Circuit
____ evaluation is when each part of an expression that uses an operator is evaluated only as far as necessary to determine whether the entire expression is true or false.
Binary
____ operators require two operands.
A
_____data items may involve organizing or sorting them, checking them for accuracy, or performing calculations with them. a. Processing b. Inputting c. Outputting d. Converting
compound operators
a combination of arithmetical and assignment operators + = Increments the value of the variable - = Decrements the value of the variable
conditional operators
a ternary operator, checks the condition in the expression and returns the output as either true or false Syntax: [Condition]? [true statement] : [false statement];
The most common way to declare a destructor explicitly is to use an identifier that consists of ____
a tilde followed by a class name
Which of the following statements about methods is correct? a) A method is a sequence of instructions that can access the data of an object b) A method name is unique across the entire program. c) A method can be called on any object in any class. d) Methods are stored in variables.
a) A method is a sequence of instructions that can access the data of an object
The purpose of inheritance is to...
build off others work
What do instance variables belong to? a) an object b) a class c) a method d) a package
a) an object
What is the name of the utility that formats comments into a set of documents that you can view in a Web browser? a) javadoc b) javac c) javad d) java
a) javadoc
Consider the following method header for an Employee class: public void raiseSalary(double percentRaise) { ______________________________________ } Fill in the blank in the method body: a) salary = salary * (1 + percentRaise); b) salary = salary * percentRaise; c) salary = salary * raise; d) salary = salary * (1 + raise);
a) salary = salary * (1 + percentRaise);
What is the decimal equivalent of each of the following binary numbers? a. 100 = b. 1011 = c. 101010 = d. 1001110 =
a. 100 = 4 b. 1011 = 11 c. 101010 = 42 d. 1001110 = 78
Directories and ____ are organization units on storage devices. Answers: a. folders b. streams c. files d. partitions
a. folders
Object-oriented programmers sometimes say an object is one ____ of a class. Selected Answer: Answers: a. instantiation b. reference c. enumeration d. member
a. instantiation
Making programs easier to use for people with physical limitations is known as enhancing ____.
accessibility
What terminology describes a method that returns information about an object and does not change the object's internal data?
accessor
A method header consists of which of the following parts? A. the return type, the name of the method, and a list of the parameters (if any) B. the type of the instance variable, an access specifier, and a list of the parameters (if any) C. an access specifier, the type of the instance variable, and the name of the instance variable D. an access specifier, a return type, a method name, and a list of the parameters (if any)
an access specifier, a return type, a method name, and a list of the parameters (if any)
A class declaration consists of which of the following parts? A. an access specifier, the keyword class, the name of the class, declarations for instance variables, constructors, and methods B. an access specifier, the name of the class, a list of the parameters (if any), and the body of the constructor C. an access specifier, a return type, a method name, a list of the parameters (if any), and the body of the method D. the name of the class, declarations for instance variables, constructors, and methods
an access specifier, the keyword class, the name of the class, declarations for instance variables, constructors, and methods
An instance variable declaration consists of which of the following parts? A. the return type, the name of the method, and a list of the parameters (if any). B. the type of the instance variable, an access specifier, a list of the parameters (if any), and the body of the method. C. an access specifier, the type of the instance variable, and the name of the instance variable. D. an access specifier, a list of the parameters (if any), and the body of the method.
an access specifier, the type of the instance variable, and the name of the instance variable.
The entire list of parent classes from which a child class is derived constitutes the ____ of the subclass
ancestors
____ is the rapid sequence of still images, each slightly different from the previous one, that produces the illusion of movement.
animation
annotated tag
are stored as full objects in the Git database. They're checksummed; contain the tagger name, email, and date; have a tagging message; and can be signed and verified with GNU Privacy Guard (GPG)
The input to a method is called a(n) _______________.
argument
All parameters of the printf method after the first parameter are called ______
arguments
Input to a method, enclosed in parentheses after the method name, is known as ______________.
arguments
Assume the method below has been added to the BankAccount class. public void transfer (BankAccount source, double amount) { balance = balance + amount; source.balance = source.balance - amount; } What will be output from the following statements that use the revised BankAccount class? BankAccount first = new BankAccount (100.0); BankAccount second = new BankAccount (300.0); first.transfer (second, 50.0); System.out.println (first.getBalance() + '' '' + second.getBalance()); a) 100.0 300.0 b) 150.0 250.0 c) 150.0 300.0 d) 100.0 250.0
b) 150.0 250.0
When you think in an object-oriented manner, every object is a member of a more general ____. Answers: a. struct b. class c. method d. collection
b. class
The process of combining all of an object's attributes and methods into a single package is ____. Answers: a. data hiding b. encapsulation c. information hiding d. inheritance
b. encapsulation
In most programming languages, before an application can use a data file, it must ____. Answers: a. close the file b. open the file c. prepare the file d. read the file
b. open the file
Which term is used to describe the name of a variable, method, or class? a) type b) literal c) identifier d) label
c) identifier
By convention, variables begin with a(n) _____________. a) uppercase letter b) digit c) lowercase letter d) dollar sign
c) lowercase letter
What terminology describes a method that modifies the internal data of its implicit parameter? a) public b) void c) mutator d) accessor
c) mutator
What is the declared return type for a method that does not have a return value? a) String b) There is no declared return type when a method does not return a value. c) void d) A method must return a value.
c) void
____ are groups of fields that go together for some logical reason. Answers: a. Columns b. Databases c. Records d. Tables
c. Records
Objects both in the real world and in object-oriented programming contain ____ and methods. Answers: a. primitive data types b. help c. attributes d. behaviors
c. attributes
A(n) ____ consists of a rectangle divided into three sections. Answers: a. class tree b. dependency diagram c. class diagram d. entity-relationship diagram
c. class diagram
What is the output of the following code: int num1 = 6; int num2 = 10; num1 = num1 + num2; num2 = num1 + num2; System.out.println(num1 + '', '' + num2); a) 6, 10 b) 16, 16 c) 16, 22 d) 16, 26
d) 16, 26
What will be output from the following statements that use BankAccount class? BankAccount first = new BankAccount (100); BankAccount second = new BankAccount (100); BankAccount third = first; first.deposit (50.0); second.deposit (50.0); third.deposit (50.0); System.out.println (first.getBalance() + '' '' + second.getBalance() + third.getBalance()); a) 150.0 200.0 250.0 b) 150.0 150.0 150.0 c) 250.0 250.0 250.0 d) 200.0 150.0 200.0
d) 200.0 150.0 200.0
What does API stand for? a) Applet Programming Interface b) Application Programmer Interaction c) Application Programming Instance d) Application Programming Interface
d) Application Programming Interface
Which statement about identifiers is correct? a) Identifiers are not case sensitive. b) Spaces are permitted inside identifiers. c) Identifiers can use symbols such as ? or %. d) Identifiers can be made up of letters, digits, and the underscore (_) character.
d) Identifiers can be made up of letters, digits, and the underscore (_) character.
Which of the methods below are static methods? I. length II. substring III. pow IV. sqrt a) All the methods are static b) Only I, II and III c) Only II and IV d) Only III and IV
d) Only III and IV
Which of the following method calls illustrates the return value of a method as a parameter? a) greeting.length(); b) greeting.println(''Hello''); c) System.out.println(count); d) System.out.println(greeting.length());
d) System.out.println(greeting.length());
Assuming the following Java statement: int num = 10; What does the variable num store? a) A reference to the memory location where the value 10 is stored. b) A reference to the int primitive type. c) An object representing the number 10. d) The numeric value 10.
d) The numeric value 10
What is the result of the following statement? String s = ''You'' + ''had'' + ''me'' + ''at'' + ''hello''; a) The string s has the following value: ''You had me at ''hello'' b) The statement results in an error because the + operator can be used only with numbers c) The statement results in an error because the + operation cannot be performed on string literals d) The string s has the following value: ''Youhadmeathello''
d) The string s has the following value: ''Youhadmeathello''
The process of finding and correcting program errors is called ____.
debugging
Which of the following terms denotes the memory location of an object? a) implicit parameter b) mutator method c) encapsulation d) object reference
d) object reference
A method name is ____________________ if a class has more than one method with that name (but different parameter types). a) overridden b) overimplemented c) overwhelmed d) overloaded
d) overloaded
Which is not a method of the String class? a) length b) toUpperCase c) toLowerCase d) println
d) println
You should declare all instance variables as ___. a) protected b) class c) public d) private
d) private
How do you extract the first 5 characters from the string str? a) substring(str, 5) b) substring.str(0, 5) c) str.substring(5) d) str.substring(0, 5)
d) str.substring(0,5)
By convention, classes begin with a(n) _____________. a) lowercase letter b) dollar sign c) digit d) uppercase letter
d) uppercase letter
A ____ is a collection of data stored on a nonvolatile device in a computer system. Answers: a. computer message b. computer interface c. computer selector d. computer file
d. computer file
Because they enable you to locate a particular record directly (without reading all of the preceding records), random access files are also called ____ files. Answers: a. pointed access b. indirect access c. sequential access d. direct access
d. direct access
Files exist on ____ storage devices, such as hard disks, DVDs, USB drives, and reels of magnetic tape. Answers: a. optical b. scalable c. transient d. permanent
d. permanent
When you copy data from a file on a storage device into RAM, you are ____ from the file. Answers: a. uploading b. writing c. outputing d. reading
d. reading
arithmetic operators
help perform mathematical operations such as addition, subtraction, multiplication and division. These operators are represented by their mathematics symbols
Computer programmers often refer to memory addresses using ____ notation.
hexadecimal
%x
hexadecimal integer
When a data field within a class is ____, no outside class can use it-including a child class.
private
git fetch [remote-name]
to get data from your remote projects
Each file in your working directory can be in one of two states
tracked or untracked
Which of the following is a mutator method for the Rectangle class?
translate
A subclass can inherit both properties and methods.
true
An important advantage of using GUI data-entry objects is that you often can control what users enter by limiting their options.
true
By using standard component classes, programmers are assured that the GUI components in their programs have the same look and feel as those in other programs.
true
Multithreaded programs often run faster and they are more user-friendly.
true
You can add an abstract method to a class you ALWAYS have to make the class abstract as well
true
What verifies that a class works correctly in isolation, outside a complete program? A. abstraction B. unit test C. enumeration D. encapsulation
unit test