CSIT 210 Exam 1, CSIT210 Quiz 4, quiz5, CSIT210 Quiz 6, CSIT210 Quiz 7, quiz8
A mnemonic is a short line of text that will appear when the cursor is rested momentarily on top of the component.
False
A panel is displayed as a separate window, but a frame can only be displayed as part of another container.
False
A programmer is required to define a constructor for every class.
False
A reserved word can be used to name a method. True False
False
A variable can always be referenced anywhere in a program.
False
A while statement always executes its loop body at least once.
False
All of the classes contained in the java.util package are automatically included in every Java program. True False
False
An identifier can begin with a digit. True False
False
An infinite loop is a compile-time error.
False
An object can be thought of as a blueprint for a set of classes.
False
Promotion is a widening data conversion that is explicitly requested by the programmer. True False
False
String objects can be changed after instantiation. True False
False
The ability of the user should be ignored when designing GUIs. In other words, GUIs should be designed with the most unskilled user in mind.
False
The byte type can be assigned a larger range of numbers than the int type. True False
False
The following snippet of code will not compile because the second part of the if statement needs to be on the second line. if(a < b) System.out.println("a is less than b");
False
The getMessage method of the Exception class prints out the stack trace, which helps the user to track down the source of the exception.
False
The grid layout organizes components into a grid of rows and columns, and also allows components to span more than one cell.
False
The keyHit event is called when a key is pressed.
False
The new operator is used to access an objects methods. True False
False
The print and the println methods are identical and can be used interchangeably. True False
False
There are times when it is appropriate to return data from a method of a type that is inconsistent with the return type specified in the method header.
False
Unchecked exceptions must be caught or propogated, or a program will not compile.
False
When called with integer parameter n, the nextInt() method of the Random class will return a randomly generated integer between 0 and n. True False
False
Which of the following layout managers organize the components from left to right, starting new rows as necessary?
Flow Layout
Which of the following best describes this code snippet? if (count != 400) System.out.println("Hello World!");
If the variable count is not equal to 400, "Hello World" will be printed.
Which of the following exceptions are unchecked?
RuntimeException
Which of the following represents the standard input stream?
System.in
A variable that is declared as a primitive type stores the actual value of the associated data. A variable that is declared as an object type stores a pointer to the associated object. True False
True
Aggregation is sometimes described as a has-a relationship
True
It is possible to implement a switch statement using if statements
True
Java is a strongly-typed language. True False
True
Multiple reference variables can refer to the same object. True False
True
The Exception class is a subclass of the Object class.
True
The Math class is part of the java.lang package. True False
True
The Scanner class must be imported using the import statement before it can be used in a program. True False
True
The System.out.printf() method is an alternative way to output information in Java. True False
True
The relational operators should not be used to test the equality of objects.
True
These two snippets of code are identical from the point of view of the compiler: //snippet 1 public static void main(String [] args) { System.out.println("Hi!"); } //snippet 2 public static void main(String [] args){System.out.println("Hi!");} True False
True
Variables declared with the final modifier cannot have new values assigned to them. True False
True
Variables that are declared as static are shared among all instances of a class.
True
When accessing an element of an array, if the index is outside of the range of the indexes of the array, an exception is thrown.
True
When an object is passed to a method, the actual and formal parameters become aliases.
True
When there are no references to an object, the object is marked as garbage and is automatically removed from memory using Java's automatic garbage collection feature. True False
True
he Scanner object can be used to read text files.
True
A _______________ is a list of characters in a particular order. Examples include ASCII and Unicode. a. character literal b. character set c. char data type d. control character e. none of the above
b. character set
Which of the following types of methods do not have any return type (not even a void return type)?
constructors
How many times is "Hi" printed to the screen? for(int i = 0;i < 14;i ++ ); System.out.println("Hi");
1
Given the following code fragment, what is the final value of y? int x, y; x = -1; y = 0; while(x < 3) { y += 2; x += 1; }
8
Suppose we have an array of String objects identified by the variable names. Which of the following for loops will not correctly process each element in the array.
for(int i = 0; i < names.length(); i++)
Which of the following will correctly assign all the values in one array to the other array? (Assume both arrays are of the same type and have SIZE elements)
for(int i = 0;i < SIZE;i ++) array1[i] = array2[i];
GUI is an acronym for _______________________.
graphical user interface
Which of the following is a valid declaration for a two-dimensional array?
int[][] matrix;
Which of the following best describes a timer component?
it generates action events at regular intervals
Executing one or more statements one or more times is known as
iteration
A _________________ is an object that has methods that allow you to process a collection of items one at a time.
iterator
Every Java array is a(n) _________________, so it is possible to use a foreach loop to process each element in the array
iterator
hat is the output of the following code fragment if x is 15? if(x < 20) if(x < 10) System.out.println("less than 10"); else System.out.println("large");
large
A container is goverened by a(n) __________________, which determines exactly how the components added to the panel will be displayed.
layout manager
A(n) ____________________ is an object that waits for an event to occur and responds in some way when it does.
listener
Which boolean operation is described by the following table? A B Operation True | True | True True | False | True False| True |True False | False | False
or
Which of the following file streams should be explicitly closed to ensure that written data is properly retained?
output
A method that has multiple definitions is an __________________ method.
overloaded
Arrays are always passed to a method using
pass by array
Which of the following classes play a role in altering a visual aspect of a component?
BorderFactory
Attempting to divide by zero will result in an Error being thrown, not an Exception.
False
Check boxes operate as a group, providing a set of mutually exclusive options.
False
Comments affect the run-time execution of a program. True False
False
Enumerated types allow a programmer to treat primitive data as objects. True False
False
Every line in a catch block is guaranteed to be executed in all situations.
False
In Java, a boolean expression is limited to having exactly 2 logical operators
False
In Java, all floating point literals are assumed to be of type float. True False
False
In order for a string literal may span multiple lines in the program code. True False
False
In practice, it is important to catch all exceptions that might be thrown by a program.
False
Java uses the ASCII character set to represent character data. True False
False
Which of the following statements best describes the flow of control in the main method of a Java program that has no conditionals or loops?
Program statements are executed linearly, with earlier statements being executed first
Suppose we wanted to process a text file called "input.txt" using the Scanner object. Which of the following lines of code correctly creates the necessary Scanner object?
Scanner inputFile = new Scanner(new File("input.txt"));
Given the following code fragment, what is the output? int x = 5; if( x > 5) System.out.println("x is bigger than 5."); System.out.println("That is all."); System.out.println("Goodbye");
That is all. Goodbye
Given the following declarations, which of the following is a legal call to this method? int myMethod(int myValue) int [] myArray = new int[1000];
b and d
Assume that logger is a reference to an object that has a method named printErrorDescription , that accepts one int argument and returns no value. Write a statement that invokes the method printErrorDescription , passing it the value 14 . a. printErrorDescription(14); b. printErrorDescription.logger(14); c. logger.printErrorDescription(14); d. printErrorDescription(14);
c. logger.printErrorDescription(14);
Which of the following is considered a logical error? a. typing a curly bracket when you should have typed a parenthesis b. dividing by zero c. multiplying two numbers when you meant to add them d. misspelling an identifier e. forgetting a semicolon at the end of a programming statement
c. multiplying two numbers when you meant to add them
Which of the following is not one of the four basic software development activities? a. implementing the design b. establishing the requirements c. preliminary practice coding d. testing e. creating a design
c. preliminary practice coding
The versions of an overloaded method are distinguished by ___________________________.
the number, type and order of their parameters
The ________________ reference always refers to the currently executing object.
this
Which of the following statements best describes this line of code? int[] numbers = new int[50];
this is the declaration and initialization of an array that holds 50 integers
The _________________ statement is used to begin exception propogation.
throw
Any Swing component can be assigned a tool tip.
true
If a program attempts to access an element outside of the range of the array indexes, a run-time error will occur
true
It is possible for a method to have a variable length parameter list, meaning that the method can take in any number of parameters of a specified data type.
true
It is possible to send in data to a Java program via the command-line
true
The foreach loop can be used to process each element of an array.
true
A logical expression can be described by a ________________ that lists all possible combinations of values for the variables involved in an expression.
truth table
A(n) ____________________ is used to identify a block of statements that may cause an exception.
try block
Assume that we have a Random object referenced by a variable called generator. Which of the following lines will generate a random number in the range 5-20 and store it in the int variable randNum? a. randNum = generator.nextInt(15) + 5; b. randNum = generator.nextInt(15) + 6; c. randNum = generator.nextInt(16) + 5; d. randNum = generator.nextInt(16) + 6; e. none of the above
c. randNum = generator.nextInt(16) + 5;
When two references point to the same object, ________________________________ . a. a run-time error will occur. b. a compiler error will occur. c. the references are called aliases of each other. d. the object will be marked for garbage collection. e. the references are called null references.
c. the references are called aliases of each other.
Software requirements specify ____________________. a. a programming schedule b. how a solution should be implemented c. what a program should accomplish d. which programming language the developer should use e. how objects should be encapsulated
c. what a program should accomplish
A(n) ____________________ can be used to find the exact line where an exception was thrown during program execution.
call-stack trace
Which of the following are valid case statements in a switch?
case 1:
A(n) ____________________ is used to specify how certain exceptions should be handled.
catch block
Which of the following components can be toggled on or off using the mouse, indicating that a particular boolean condition is set or unset?
check box
Which of the following exception types must always be caught unless they are contained in methods that throw them in the method header?
checked
Which of the following components allows the user to select one of several options from a "drop down" menu?
combo boxes
A(n) ___________________ is an object that defines a screen element used to display information or allow the user to interact with a program in a certain way.
component
The ___________________ statement causes current iteration of a loop to stop and the condition to be evaluated again, either stopping the loop or causing the next iteration
continue
A _____________________ container is one that is managed by the underlying operating system on which the program is run, whereas a __________________ container is managed by the Java program itself.
heavyweight, lightweight
Which of the following expressions best represents the condition "if the grade is between 70 and 100"
if (75 < grade && grade < 100)
Given the following code fragment, which of the following expressions is always true? int x; x = scan.nextInt();
if( x = 1)
Suppose we want to condition an if statement on whether two String objects, referenced by stringOne and stringTwo, are the same. Which of the following is the correct way to achieve this?
if(stringOne.equals(stringTwo))
What is the final value of x after the following fragment of code executes? int x = 0; do { x++; }while(x > 0);
infinite loop
What is wrong with the following for loop? for(int i = 0;i < 10;i -- ) { System.out.println("Hello"); }
infinite loop
Given the following code fragment, and an input value of 5, what is the output? int x; if( x < 3) { System.out.println("small"); } else { if( x < 4) { System.out.println("medium"); } else { if( x < 6) { System.out.println("large"); } else { System.out.println("giant"); } } }
large
Which of the following components allows the user to enter typed input from the keyboard.
none of the above
Which of the following lines of code accesses the second element of the first array in a two-dimensional array of integers, numbers, and stores the result in a variable called num?
num = numbers[0][1];
Which of the following methods are part of the Exception class and can be used to give information about a thrown exception?
printStackTrace
If a service is so complex that it cannot be reasonably be implemented using one method, it is often helpful to decompose it to make use of ________________ support methods.
private
When applied to instance variables, the ________________ visibility modifier enforces encapsulation.
private
Which of the following method declarations correctly defines a method with a variable length parameter list?
public int average(int ... list)
Which of the following method headers is most likely a header for a mutator method?
public void setAge(int newAge)
Multi-dimensional arrays that contain arrays of different lengths in any one dimension are called _________________.
ragged arrays
Given an array named scores with 25 elements, what is the correct way to access the 25th element?
scores[24]
A _______________ variable is shared among all instances of a class.
static
Methods that can be called directly through the class name and do not need to have an object instantiated are called _________________.
static
A(n) ________________ is an ordered sequence of bytes.
stream
If an exception is not caught, a program will __________________________ .
terminate abnormally
An object should never be encapsulated. True False
False
Which of the following logical operators has the highest precedence?
!
Which of the following boolean expressions tests to see if x is between 2 and 15 (including 2 and 15)?
(x >= 2 && x <= 15)
In Java, array indexes always begin at ________________ .
0
What is the value of i after the following code fragment? int i = 5; switch(i) { case 0:i = 15;break; case 1:i = 25;break; case 2:i = 35;break; case 3:i = 40;break; default:i = 0; }
0
What are the valid indexes for the array shown below? int [] myArray = new int [25];
0-24
Given the following code fragment, what is the final value of y? int x, y; x = -1; y = 0; while(x <= 3) { y += 2; x += 1; }
10
What will be the output of the following code snippet? int[] array = new int[25]; System.out.println(array.length);
25
Given the following code fragment and the input value of 4.0, what output is generated? double tax; double total; System.out.print("Enter the cost of the item"); total = scan.nextDouble(); if ( total >= 3.0) { tax = 0.10; System.out.println(total + (total * tax)); } else { System.out.println(total); }
4.4
Given the following code, what is the final value of i? int i; for(i = 0; i <= 4;i ++ ) { System.out.println(i); }
5
Which of the following is not a valid relational operator in Java
<>
A dialog box allows the user to select one of several options from a "drop down" menu.
False
A finally clause is always required in a try-catch block.
False
What is wrong with the following code fragment? final int SIZE = 5; double scores[SIZE]; for(int i = 0; i <= SIZE;i ++) { System.out.print( "Enter a score "); scores[i] = scan.nextDouble(); }
Array indexes must be less than the size of the array.
Which of the following is a true statement?
Arrays are passed as parameters to methods like object types.
An interpreter is a program that translates code that is written in one language into equivalent code in another language. True False
False
A(n) _____________________ is an object that defines an unusual or erroneous situation that is typically recoverable.
Exception
What is the precedence of the index operator ( [ ] ) relative to other operators in Java?
It has the highest precedence of all Java operators.
Let a and b be valid boolean expressions. Which of the following best describes the result of the expression a || b?
It will evaluate to false if a evaluates to false and b evaluates to false. It will evaluate to true otherwise
Which of the following are true about two-dimensional arrays?
None of the above are true.
Which of the following event descriptions best describes the mouse entered event?
The mouse pointer is moved onto a component
What happens if a case in a switch statement does not end with a break statement?
The switch statement will execute the next case statement as well.
Which of the statements is true about the following code snippet? int[] array = new int[25]; array[25] = 2;
This code will result in a run-time error.
The Exception class and the Error class are subclasses of the ___________________ class.
Throwable
A Scanner object can use delimiters other than a space.
True
A color chooser is a dialog box.
True
A main method can only access static or local variables.
True
A return statement is not required at the end of every method.
True
A throw statement is used to begin exception propagation
True
An exception will be propagated until it is caught and handled or until it is passed out of the main method.
True
Identifiers can be of any length. True False
True
In Java, array indexes begin at 0 and end at one less than the length of the array.
True
In Java, total, ToTal and TOTAL are all different identifiers. True False
True
In a class that has variables called height and width, methods called getHeight() and getWidth() are examples of accessor methods.
True
In a nested if statement an else clause is matched to the closest unmatched if.
True
Java is case-sensitive. True False
True
Layout managers determine how components are visually presented.
True
Syntax rules dictate the form of a program. Semantics dictate the meaning of the program statements. True False
True
The type of result produced by a mathematical expression depends on the types of the operands. True False
True
A ________________ diagram helps us visualize the contents of and relationships among the classes of a program.
UML
Consider the expression: result = 15 % 4; What value stored in result after this line is executed? a. 0 b. 1 c. 2 d. 3 e. 4
d. 3
All methods (with the exception of constructors) must specify a return type. What is the return type for a method that does not return any values?
Void
Write a String constant consisting of exactly one character - A. a. System.out.print(""); b. System.out.print( ); c. System.out.print(''); d. none of the above
a. System.out.print("");
Write a String constant that is the empty string . a. System.out.print(""); b. System.out.print( ); c. System.out.print(''); d. none of the above
a. System.out.print("");
Which of the following statements will assign the first command-line argument sent into a Java program to a variable called argument?
argument = args[0];
Which of the following best describes what happens when an object no longer has any references pointing to it? a. The object is marked as garbage and its associated memory is freed when the garbage collector runs. b. The object is immediately deleted from memory. c. The object stays in memory for the remainder of the programs execution. d. The object is overwritten the next time the new operator is called. e. The object is overwritten the next time the new operator is called using the same class.
a. The object is marked as garbage and its associated memory is freed when the garbage collector runs.
The character escape sequence to force the cursor to advance forward to the next tab setting is: a. \t b. \tab c. \T d. \\t
a. \t
Assume that dataTransmitter is a variable that refers to an object that provides a method, sendSignal that takes no arguments. Write the code for invoking this method. a. dataTransmitter.sendSignal(); b. dataTransmitter.sendSignal; c. sendSignal.dataTransmitter(); d. dateTransmitter.sendSignal();
a. dataTransmitter.sendSignal();
Assume that dateManager is a reference to an object that has a method named printTodaysDate , that accepts no arguments and returns no value. Write a statement that calls printTodaysDate . a. dateManager.printTodaysDate( ); b. printTodaysDate(); c. dateManager.printTodaysDate; d. dataManager.printTodaysDate();
a. dateManager.printTodaysDate( );
Declare an integer constant, DAYS_IN_MAY , whose value is 31. a. final int DAYS_IN_MAY = 31; b. final String DAYS_IN_MAY = "31"; c. final int DAYS_IN_YEAR = 31; d. final INT DAYS_IN_MAY = 31;
a. final int DAYS_IN_MAY = 31;
Which of the following lines allows a programmer to use the Scanner class in a Java program? a. import java.util.Scanner; b. using Scanner; c. include Scanner; d. include java.util.Scanner; e. any of the above will allow the programmer to use the Scanner class
a. import java.util.Scanner;
Which of the following is a valid comment? a. int age; /* the age of the user */ b. int age; /*// the age of the user //*/ c. int age; */ the age of the user /* d. int age; //* the age of the user //*
a. int age; /* the age of the user */
The String class _______________________________ . a. is part of the java.lang package. b. is part of the java.util.package. c. is a wrapper class. d. none of the above. e. all of the above.
a. is part of the java.lang package.
The _____________ of an object define it define its potential behaviors. a. methods b. attributes c. name d. white spaces e. variables
a. methods
When an object variable is declared but it is not assigned a value, it is called a ______________________. a. null reference b. static reference c. zero reference d. void reference e. empty reference
a. null reference
Consider the following snippet of code: Random generator = new Random(); int randNum = generator.nextInt(20) + 1; Which of the following will be true after these lines are executed? a. randNum will hold a number between 1 and 20 inclusive. b. randNum will hold a number between 0 and 20 inclusive. c. randNum will hold a number between 1 and 21 inclusive. d. these lines will not be executed because a compiler error will result. e. none of the above
a. randNum will hold a number between 1 and 20 inclusive.
__________________ parameters are the values that are used when calling a method.
actual
A(n) ___________________ object is one that is made up, at least in part, of other objects.
aggregate
A(n) ________________ is a step-by-step process for solving a problem.
algorithm
Which of the following is a fundamental idea of good GUI design?
all of the above
Which of the following array declarations are invalid?
all of the above are valid
Which boolean operation is described by the following table? A B Operation True -True-True True -FalseFalse False-True-False False-False-False
and
What is wrong with the following switch statement? int ans; System.out.print("Type y for yes or n for no"); ans = scan.nextInt(); switch (ans) { case 'y': case 'Y': System.out.println("You said yes");break; case 'n': case 'N': System.out.println("You said no");break; default: System.out.println("invalid answer"); }
ans is a int
The ___________________ statement causes execution of a loop to stop, and the statement following the loop to be subsequently executed.
break
Consider the expression: result = 12 + 5 / 2; What value stored in result after this line is executed? a. 8.5 b. 14 c. 14.5 d. this will result in a compiler error e. 9
b. 14
Consider the following snippet of code: System.out.println("30 plus 25 is " + 30 + 25); What is printed by this line? a. 30 plus 25 is 55 b. 30 plus 25 is 3025 c. 30 plus 25 is 30 d. 30 plus 25 is 25 e. this snippet of code will result in a compiler error
b. 30 plus 25 is 3025
Information is most likely to be lost in what kind of data conversion? a. A widening conversion b. A narrowing conversion c. promotion d. assignment conversion e. no information will be lost in any of the conversions listed above
b. A narrowing conversion
____________________ is the automatic conversion between a primitive value and a corresponding wrapper object. a. Number formatting b. Autoboxing c. Aliasing d. Generating e. Static invocation
b. Autoboxing
Which of the following classes include the getCurrencyInstance() method? a. String b. NumberFormat c. DecimalFormat d. Math e. none of the above
b. NumberFormat
Assume there is a class AirConditioner that supports the following behaviors: turning the air conditioner on and off, and setting the desired temperature. The following methods provide this behavior: turnOn and turnOff , and setTemp , which accepts an int argument and returns no value. Assume there is a reference variable myAC to an object of this class, which has already been created. Use the reference variable, to invoke a method that tells the object to set the air conditioner to 72 degrees. a. myAC.turnOn(72); b. myAC.setTemp( 72 ); c. myAC.turnOn(); myAC.setTemp(72); d. myAc.setTemp(72);
b. myAC.setTemp( 72 );
The ________________ operator is used to instantiate an object. a. static b. new c. + d. - e. none of the above
b. new
In Java, an identifier that is made up by the programmer can consist of ___________________. a. only numbers b. numbers, letters, the underscore ( _ ), and the dollar sign ( $ ) c. only letters d. any characters e. only letters, the underscore ( _ ), and the dollar sign ( $ )
b. numbers, letters, the underscore ( _ ), and the dollar sign ( $ )
Assume there is a class AirConditioner that supports the following behaviors: turning the air conditioner on and off, and checking if the air conditioner is on or off. The following methods provide this behavior: turnOn and turnOff , setTemp , and isOn , which accepts no argument and returns a boolean indicating whether the air conditioner is on or off. Assume there is a reference variable myAC to an object of this class, which has already been created. a. status = myAC.isOn b. status = myAC.isOn( ); c. myAC.status(); d. myAC.isOn()
b. status = myAC.isOn( );
Which of the following is an example of an invalid assignment or declaration statement? a. int age = 30; b. int money, dollars = 0, cents = 0; c. int years = 1; months = 12; days = 365; d. int length, meters, centimeters, millimeters; e. none of the above
c. int years = 1; months = 12; days = 365;
Java has two basic kinds of numeric values: _____________, which have no fractional part, and ___________________ which do. a. shorts, longs b. characters, bytes c. integers, floating points d. doubles, floating points e. integers, longs
c. integers, floating points
Which of the following is not a valid Java identifier? a. thirdNumber b. answer_7 c. 2ndlevel d. highest$ e. anExtremelyLongIdentifierIfYouAskMe
c. 2ndlevel
The Java compiler translates Java source code into _____________ . a. assembly code b. C++ c. Java bytecode d. an object-oriented language e. machine code
c. Java bytecode
Which of the following represents the proper way to create a NumberFormat object that formats numbers as percentages? a. NumberFormat fmt = new NumberFormat(%); b. NumberFormat fmt = new NumberFormat("%"); c. NumberFormat fmt = NumberFormat.getPercentInstance(); d. NumberFormat fmt = new PercentNumberFormat(); e. none of the above
c. NumberFormat fmt = NumberFormat.getPercentInstance();
Write a statement that prints Hello, world to the screen. a. System.out.println("Hello, world") b. system.out.println("Hello, world"); c. System.out.println("Hello, world"); d. System.out.println('Hello, world');
c. System.out.println("Hello, world");
A syntax error is a _____________________. a. a run-time error b. a bug c. a compile-time error d. an exception e. a logical error
c. a compile-time error
Java is _____________________. a. a spoken-language b. a functional language c. an object-oriented language d. a fourth-generation language e. a procedural language
c. an object-oriented language
Which of the following for loop headers will cause the body of the loop to be executed 10 times?
for(int i = 0; i < 10; i++)
Suppose we have a String object referenced by a variable called listing. Suppose we want a new String object that consists of the first 5 characters in listing. Which of the following lines of code will achieve this? a. String prefix = listing.front(5); b. String prefix = listing.front(6); c. String prefix = listing.substring(1,5); d. String prefix = listing.substring(0,5); e. String prefix = listing.firstChars(5);
d. String prefix = listing.substring(0,5);
Which of the following is a valid Java identifier? a. Fourth_&_goal b. 2_%_2 c. Studio#54 d. _____________
d. _____________
In order for a program to run on a computer, it must be expressed in ______________________. a. a high-level language b. an object-oriented language c. an assembly language d. a machine language e. a fourth generation language
d. a machine language
What can be included in a comment? a. reserved words b. special characters c. user output d. all of the above
d. all of the above
Which of the following might be included in an IDE? a. a compiler b. an editor c. a debugger d. all of the above e. none of the above
d. all of the above
Writing a floating point literal corresponding to the value of 0. a. 0f b. 0.0 c. 0.0f d. all of the above
d. all of the above
Which of the following data types only allows one of two possible values to be assigned? a. long b. char c. int d. boolean e. float
d. boolean
A special method that is invoked to set up an object during instantiation is called a ___________________. a. destructor b. creator c. dot operator d. constructor e. new method
d. constructor
Which of the following is a correct declaration of enumerated type for the suits of a deck of cards? a. enumerated type Suit = {hearts, spades, diamonds, clubs }; b. enum Suit {hearts, spades, diamonds, clubs }; c. enumerated type Suit = { hearts, spades, diamonds, clubs }; d. enum Suit {hearts, spades, diamonds, clubs } e. enum Suit = { hearts, spades, diamonds, clubs }
d. enum Suit {hearts, spades, diamonds, clubs }
In order to make a variable a constant which modifier must be included in its declaration? a. public b. private c. void d. final e. static
d. final
Which of the following is not a reserved word? a. static b. this c. public d. main
d. main
Which of the following expressions correctly compute 5 + 26? a. result = 5 + 2^6; b. result = 5 + 2*exponent(6); c. result = 5 + 2*Math.exponent(6); d. result = 5 + Math.pow(2, 6); e. none of the above
d. result = 5 + Math.pow(2, 6);
Which of the following describes the act of ensuring that a program solves the intended problem in all cases? a. implementing the design b. creating a design c. establishing the requirements d. testing e. preliminary practice coding
d. testing
A(n) _______________________ is a graphical window that pops up on top of any currently active window so that the user can interact with it.
dialog box
A _______________ loop always executes its loop body at least once.
do
Consider the following snippet of code: int firstNum = 25; int seconNum = 3; double result = 25/3; System.out.println(result); What is output by this code? a. 8.3 b. 8.333333333 c. This snippet of code will result in a compiler error d. 8 e. 8.0
e. 8.0
_____________ consists of specific words and symbols to express a problem solution. a. An application b. A computer c. Hardware d. Software e. A programming language
e. A programming language
Which of the following is not an arithmetic operation in Java? a. + b. - c. * d. % e. These are all arithmetic operations in Java
e. These are all arithmetic operations in Java
Which of the following lines is a properly formatted comment? a. // This is a comment b. /* This is a comment */ c. /* this is a comment */ d. both a and b e. a, b and c
e. a, b and c
Which of the following is an invalid way to instantiate a String object? a. String title = new String("Java Software Solutions"); b. String name = "John Lewis"; c. String empty = ""; d. String alsoEmpty = new String(""); e. all of the above are valid
e. all of the above are valid
Classes can be created from other classes by using _______________ . a. machine code b. attributes c. polymorphism d. encapsulation e. inheritance
e. inheritance
Which of the following are examples of invalid string literals? a. "Hello World!" b. "4 score and 7 years ago, our forefathers brought forth..." c. "z" d. "" e. none of the above
e. none of the above
A(n) ________________ is a piece of data that we send to a method. a. service b. expression c. escape sequence d. object e. parameter
e. parameter
Which of the following is an example of an invalid expression in Java? a. result = firstNum % secondNum; b. result = firstNum / secondNum % thirdNum; c. result = a + b; d. result = (14 + 9) * 5; e. result = ((19 + 4) - 5;
e. result = ((19 + 4) - 5;
Which of the following object-oriented principles refers to the fact that an object should have its data guarded from inappropriate access?
encapsulation
A(n) _____________________ is an object that defines an erroneous situation from which the program usually cannot recover
error
An array cannot hold object types.
false
An array declared as an int[] can contain elements of different primitive types.
false
Every if statement requires an associated else statement, but not every else statement requires an associated if statement.
false
If x is 0, what is the value of (!x == 0)?
false
In Java it is not possible to have arrays of more than two dimensions.
false
It is possible to store 11 elements in an array that is declared in the following way. int[] array = new int[10];
false
There is only one way to declare and initialized an array in Java.
false
Which of the following represents a dialog box that allows the user to select a file from a disk or other storage medium?
file chooser
Every line of a(n) __________________ is executed no matter what exceptions are thrown.
finally block