CS 1054 FINAL True/False QC
A Java compiler translates Java byte code into source code.
False
A String object cannot be created with a new operator.
False
A class can only implement one interface at a time.
False
A class must have a getter and setter method for each instance variable.
False
A constructor cannot be overloaded.
False
A getter method always returns an integer value.
False
An ellipses (...) is used to specify a method that accepts command-line arguments.
False
Characters in Java are represented using the ASCII character set.
False
Each value of a case can be a constant, variable, or expression.
False
If A is true and B is false, what is the value of the expression A && B?
False
If both operands to the remainder operator (%) are positive, a divisor of n will produce a result in the range 1 to n.
False
In Java, object reference variables do not have to be declared.
False
In a program, a class must always be referred to using its fully qualified name.
False
Java programs cannot be run on a web page.
False
Java was created by the Oracle Corporation, and is now managed by Sun Microsystems.
False
String is a Java primitive type
False
The Java keyword new is a method that can be called to create objects.
False
The compiler will issue an error if you violate a Java programming convention.
False
The element type of an array can be any type except boolean.
False
Using the Java API in a program is a rare occurrence
False
Within a class, methods must have unique names.
False
The body of a while loop may never execute.
False The condition is checked first, and if it's false right away, the body of the loop is never executed.
If an array can hold N values, the valid indexes for that array range from 0 to N
False 0 to N-1
A Polyline is a closed shape
False A Polygon is closed, but a Polyline is not.
A for-each loop can be used to fill the values in an array.
False A for-each loop provides access to the elements in the array, but not to the array itself
A variable-length parameter list is specified by inserting a colon (:) between the type and the parameter name.
False A variable-length parameter is specified using an ellipses (...) between the type and parameter name.
Only strings with alphabetic characters can be compared using the compareTo method
False Any Unicode characters can be compared, including punctuation and digits.
Encapsulation makes is difficult for hackers to access your data.
False Encapsulation is not about guarding against security breeches
A one-dimensional array has only one element type, but a multidimensional array can hold several types of elements.
False Every array has a single element type. The difference is in how the values are arranged
A binary search works best on an unsorted list of values
False For binary search to work at all, the list of values must already be sorted.
An array of values must be passed to the constructor of a Polygon or Polyline.
False For either, the constructor can take a variable number of double values directly, or the vertices can be added later.
You cannot use command-line arguments in IDEs like Eclipse and NetBeans.
False In IDEs, program arguments are specified using a menu option or a separate tab in the Run window.
A binary search only works if the number of elements to search is odd.
False In that case, the "middle" element will be the first of the two middle elements.
A method can only be an accessor or a mutator but not both.
False It can be both, such as a method that changes an instance value and then returns the new value.
A runtime error occurs when a printf field width is insufficient to display a value
False It grows to accommodate the larger value.
The assignment operator has higher precedence than the arithmetic operators
False It has the lowest precedence of all operators
The Java Development Kit (JDK) is an example of an integrated development environment (IDE).
False It is a "command-line" environment.
The control variable must be declared in the for loop header.
False It often is, but might also be declared previously.
The compareTo method returns one of three values: -1, 0, or 1.
False It returns a negative integer, positive integer, or 0 (not necessarily -1 or 1).
Calling the System.exit method is the best way to terminate a program.
False It's best to exit "#dq8cleanly,"#dq8 but System.exit can be convenient when no further processing is required
The body of a for loop is always executed at least once.
False Like a while loop, if the condition is false initially, the body is never executed
A Scanner object can be used to both read and write text files in Java.
False No, a Scanner object is only used for input.
The relational operators can be used to put String objects in alphabetical order
False Objects like < can't be applied to objects
A linear search examines every element in the array.
False Once the target element is found, there is no need to keep searching the array
A null string and an empty string are equal.
False One is a reference that doesn't point to any object, while the other is a valid string that contains no characters.
The expression in a switch statement can be an int or double value.
False Only int, character, or enumeration constatnt (no floating point)
The println method accepts a variable number of parameters.
False Only takes one
The arithmetic operators have a lower precedence than the relational operators
False Other way around
Our implementation of a prime sieve uses an array of integers and sets the values to 0 when they are found not to be prime.
False Our implementation uses an array of boolean values, whose index values are determined to be prime or not
Java represents a color using the CMYK color model
False RGB Color model
Using the this reference is mandatory with all instance data references inside a method.
False Sometimes it is necessary, but most often the this is helpful for making code more readable.
A String object is immutable, which means it is created using the new operator
False Strings are immutable, but that means they cannot be changed once created
Unlike other loops, the do-while loop is not considered a repetition statement.
False Sure it is. Java has four repetition statements: while, do-while, for, and for-each
Constructors cannot be overloaded.
False Sure they can, and often are. Overloaded constructors provide different ways to set up an object.
Text color is determined by the font applied to a Text object.
False Text color is specified using the setFill method of the Text class.
When creating a Text object, you specify the position on which you want the text centered
False The coordinates specify where the leading (left) edge of the text begins
If left unspecified, the font applied to a Text object is 12 point Lucinda Grande.
False The default font used depends on the operating system running the program
Arrays can hold primitive types, but not objects
False The element type of an array can be either a primitive type or an object reference
To change the algorithm for finding a minimum value into one that finds a maximum value, the condition of the for loop would change
False The for loop could stay the same -- the condition of the if statement would change to find the biggest element.
The constructor of the Person class is called constructPerson.
False The name of a constructor always matches the name of the class.
The classic format for a getter method is to use the word "access" in front of the variable name
False The name of a getter method starts with "get". A method that returns a variable width is called getWidth.
Getter methods always return a String
False The return type of each getter method must match the type of the value being retrieved.
If the x position of a line's end point is bound, so must the y position, and vice versa
False The x and y values of a point can be bound independently.
There are exactly six primitive data types in Java.
False There are 8
A Polygon or Polyline can have at most 10 vertices.
False There is no practical limit on the number of vertices in either.
If bound, the x and y position of a line's end point must be bound to the same property.
False They can be bound to different properties, or not at all.
An object must be created when its object reference variable is declared
False They can be separate activities
A printf format specifier of %.3f will print a floating-point value truncated to 3 decimal places.
False Value is rounded, not truncated
The less than operator (<) should not be used to compare floating-point values
False You can
To be sure have found all possible prime numbers up to a certain number N, you need to repeat the sieve algorithm all the way up to N.
False You only have to use the sieve algorithm up to the square root of N
The String class is part of the java.util package.
False java.lang
The classes of the java.util package are automatically imported into every Java program.
False java.lang is only one
The not operator (!) requires two operands.
False only has one operand
A String literal cannot span multiple lines in a Java program
True
A for-each loop can always be translated into an equivalent for loop.
True
A for-each loop can be used to compute the sum of all values in an array.
True
A for-each loop cannot be used to print the elements in an array backwards
True
A for-each loop cannot be used to set the values in an array.
True
A for-each loop cannot be used to store values in an array.
True
A method that accepts a variable-length argument list can be passed a previously declared array.
True
A two-dimensional array is really a one-dimensional array of one-dimensional arrays
True
A two-dimensional array is suitable for storing tabular data.
True
An ArrayList is a collection that can be processed using a for-each loop.
True
An encapsulated object keeps other objects from changing the values of its instance data.
True
Arguments passed to a variable-length argument list are accessed in the method using an array.
True
By convention, Java command-line options begin with a dash, such as -o or -b.
True
Classes should be designed to have well-defined and limited interactions with other classes.
True
Command-line arguments are commonly used to specify program options when a program is run.
True
Constants can be declared with public visibility without violating encapsulation.
True
Finding a minimum value requires that every element in the array be considered
True
If A and B are both true, what is the value of the expression A || B?
True
If an instantiation list is used to create an array, the new operator is not used.
True
If obj1 and obj2 point to the same object, then obj1 == obj2 is true.
True
If you try to access an element outside of the valid index range for an array, an exception will be thrown.
True
In Java, an array is an object.
True
In a JavaFX Polygon object, the last vertex point is automatically connected to the first.
True
It is possible to create an array with more than two dimensions.
True
Java is a general-purpose programming language.
True
Java is an object-oriented programming language.
True
Java performs automatic garbage collection.
True
Java was created by a development team led by James Gosling
True
Most professional software developers avoid the do-while loop.
True
Scaling a JavaFX Group object causes each element in the group to be scaled by the same amount.
True
Swapping two elements in an array requires three assignment statements
True
The == operator tests for reference equality.
True
The Greek mathematician Eratosthenes came up with the idea of using a sieve algorithm to find prime numbers.
True
The Java keyword this is an explicit reference to the object on which a method is invoked.
True
The JavaFX graphics framework is designed to replace older technologies such as Swing and AWT.
True
The functionality of a for loop can always be written as a while loop.
True
The instanceof operator determines if an object reference variable is currently pointing to an object of a particular type.
True
The main method accepts an array of String as a parameter.
True
The maximum indexes of a two-dimensional array with 6 rows and 10 columns are 5 and 9, respectively.
True
The methods in a Java interface are abstract.
True
The printf method accepts a variable number of parameters.
True
The printf method is an example from the Java API that uses a variable-length parameter list.
True
The result of a relational operator can be assigned to a boolean variable.
True
The this reference can be used to call one constructor from another.
True
The values passed to a Polygon constructor represent the vertices of the polygon.
True
Traversing an array or collection means accessing each element one at a time.
True
Value equality is when the contents of two objects are the same.
True
Variables declared within a method cease to exist when the method returns control to the caller.
True
You cannot use relational operators (such as < or >) on objects.
True
An output file should always be closed when you're done using it or data may be lost.
True Forgetting to close an output file is a common error.
If A is true and B is false, then the expression A || B is true.
True If either operand is true it is true
Java source code cannot be executed directly by a computer
True It must first be translated into an executable form.
File I/O operations may throw checked exceptions.
True Since they are checked, your code must either handle them explicitly or at least acknowledge they may occur.
The return type of a method is not part of the method signature.
True The return value of a method can be ignored, so it doesn't help identify the method declaration to use
The signatures of all methods within a class must be unique.
True The signatures of all methods within a class must be unique.
The println method in the Java API is overloaded
True There's many versions of println. Each one accepts a single data element to print.
The print and println methods can be used to write data to a PrintWriter object
True They work just as they do in the System.out object.
An alpha channel value of 1.0 represents a fully opaque color.
True This is the default.
A Java interface cannot be instantiated
True Unlike a class, you cannot create an object from an interface.
Objects created from the Color class are immutable.
True Values can't be changed
The Text class and the Font class are part of the same package.
True javafx.scene.text
A String method can be called through a string literal.
True
A break statement is used at the end of each case of a switch statement to keep processing from continuing into the next case
True
A constant is created using the final modifier
True
A constant should not be declared with public visibility
True
A constructor of a class has the same name as the class.
True
A for loop could always be written as an equivalent while loop.
True
A numeric literal is an explicit number used in a program.
True
A rectangle's corners can be rounded using calls to the setArcWidth and setArcHeight methods.
True
A static import let's you refer to a static method without using its class name
True
A switch statement can always be rewritten as a series of nested if statements.
True
A widening conversion converts a primitive value to a larger primitive type.
True
An entire package can be imported using one import statement
True
An import statement tells the compiler which class you're referring to in a program.
True
Arial is an example of a font family.
True
Constants make maintenance tasks easier.
True
Each Person object has its own identification number.
True
Either end point of a line segment can be designated as the "start point."
True
Elements of the Java API are organized into packages.
True
Following a null reference will cause an exception to be thrown.
True
Full documentation about the Java API can be found online.
True
If either or both operands to the division operator (/) are floating-point values, then the result will be a floating-point value.
True
In some cases, a sentinel value can be used to signal the end of input.
True
Switch statements can only test equality; they cannot make relational comparisons like greater than (>).
True
The 'int' and 'short' data types both represent integers
True
The Java Virtual Machine is software.
True
The Math class contains a constant that represents the value pi to several digits.
True
The Math.PI constant represents pi to 15 decimal places
True
The body of a do-while loop is always executed at least one time
True
The expression count++ can stand as a statement on its own.
True
The field width in a printf format specifier determines the total number of characters to be used to print the value.
True
The first parameter to the printf method is the format string
True
The format method of the String class accepts the same parameters as the printf method.
True
The human eye has three types of color receptors that correspond to wavelengths of red, green, and blue.
True
Two classes can have the same name if they are in different packages.
True
Using a while loop to check each input value for correctness is a form of input validation.
True
Whether text is displayed in bold or italic type is a function of the font object applied to the text
True
Numeric primitive values in Java are signed.
True + or -
The toString method is automatically called when an object is printed.
True And when an object is concatenated with a string
If A and B are both false, then the expression A && B is false.
True Both have to be false
A printf format specifier changes the value in the corresponding parameter
False
A type cast is used to change the data type of a variable.
False
If A is false, then the B operand in the expression A || B is not evaluated.
False
Java constants cannot be created for floating-point values.
False
The exclusive or operator (^) produces results that are opposite to the regular or operator (||).
False
The expression x^y raises the value x to the power y.
False
The methods of the Math class are called through the class name because they are abstract.
False
An import statement should be written inside a class but before any methods.
False Above the class
The increment section of the for loop header always adds 1 to the loop control variable.
False Although its called the increment section, you can update the control variable in any way you'd like.
The byte data type represents a true or false value.
False Boolean
Internally, an uppercase letter ('A') is treated the same as its lowercase version ('a').
False Case sensitivity
The 'float' and 'long' data types both represent floating-point values.
False Long represents a long integer
The parameters to the Rectangle constructor represent the upper left corner and lower right corner of the rectangle.
False The first two represent the upper left corner, but the last two represent the rectangle's width and length, respectively
The font applied to a Text object determines whether that text is underlined or not.
False The font applied to a Text object determines whether that text is underlined or not.