



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




(Quiz 0) Which of the following is true? a) Java applications can run on different platforms, like Windows and Unix, without being recompiled. b) C++ applications have always run more slowly than Java applications. , In contrast to Java c) C# requires programmers to manage almost all memory operations. d) All of the those answers. CORRECT ANSWERS a) Java applications can run on different platforms, like Windows and Unix, without being recompiled. (Quiz 0) Which of the following is not a benefit of using an IDE? a) The syntax of your code is checked as you enter it. b) The debugging features make it easier for you to find bugs in your applications c) The IDE helps you complete code as you type d) Your code compiles and runs faster. CORRECT ANSWERS d) Your code compiles and runs faster. (Quiz 0) The extension for a Java source file is a) txt b) Class c) Java d) Jav CORRECT ANSWERS c) Java (Quiz 0) You typically use comments in a Java application to a) describe statements that are difficult to understand b) separate blocks of code c) provide user instructions d) None of the above CORRECT ANSWERS a) describe statements that are difficult to understand (Quiz 0) Which of the following is a valid variable name? a) salesTax b) input-string c) 25Percent d) double CORRECT ANSWERS a) salesTax (Quiz 0) According to standard naming conventions, which of the following is a typical class name? a) $Calculate
b) calculateTotal c) Product d) product CORRECT ANSWERS c) Product (Quiz 0) Which of the following is a valid statement for declaring and initializing a double variable named length to a starting value of 120? a) length = 120.0; b) Double length = 120.0; c) double length = 120.0; d) double length = 120.0 CORRECT ANSWERS c) double length = 120.0; (Quiz 0) Which of the following can you assign to a String variable? a) an empty string b) null c) a string literal d) all of the above CORRECT ANSWERS d) all of the above (Quiz 0) If a class contains a main method, that method is executed a) when the class is run b) when another method within the class calls it c) when an object is created from the class d) none of the above CORRECT ANSWERS a) when the class is run (Quiz 0) You use an escape sequence to a) indicate the beginning of a literal string b) include a special character in a string c) indicate the beginning of a comment d) append a string expression to a string variable CORRECT ANSWERS b) include a special character in a string (Quiz 0) What does the following statement do in a Java application? import java.util.Scanner; a) It makes the Scanner class available to the application without qualification. b) It makes the classes of the Scanner package available to the application c) It copies user entries into the main method of the application. d) It looks for syntax errors in the application. CORRECT ANSWERS a) It makes the Scanner class available to the application without qualification. (Quiz 0) You can use relational operators to a) compare string variables b) compare numeric variables c) both a and b d) neither a nor b CORRECT ANSWERS b) compare numeric variables (Quiz 0) Unlike regular methods, a static method
b) data structure c) collection d) primitive CORRECT ANSWERS b) data structure (Quiz 1) An object that groups other objects and provides services to its clients is called a/an: a) abstract data type b) data structure c) collection d) primitive CORRECT ANSWERS c) collection (Quiz 1) Which of the following is not true with regard to bags? a) objects are in a specific order b) can contain duplicate items c) is an abstract data type d) is a kind of collection in Java CORRECT ANSWERS a) objects are in a specific order (Quiz 1) Which behavior is not represented in a bag? a) report the number of items in the bag b) reorder the bag c) report if the bag is empty d) add an item to the bag CORRECT ANSWERS b) reorder the bag (Quiz 1) Which method returns a count of the current number of items in a bag? a) size() b) getSize() c) getCurrentSize() d) currentSize() CORRECT ANSWERS c) getCurrentSize() (Quiz 1) Which method removes all entries of a bag? a) clear() b) remove() c) delete() d) empty() CORRECT ANSWERS a) clear() (Quiz 1) Which method removes one unspecified entry from a bag if possible? a) clear () b) remove() c) delete() d) empty() CORRECT ANSWERS b) remove() (Quiz 1) Which behaviors change the contents of a bag? a) clear() b) remove() c) add()
d) all of the above CORRECT ANSWERS d) all of the above (Quiz 1) Which method can be used to retrieve all of the elements of a bag? a) toArray() b) printBag() c) displayBag() d) getAllItems() CORRECT ANSWERS a) toArray() (Quiz 1) Which behavior(s) change the contents of a bag? a) toArray() b) add() c) contains() d) getFrequencyOf() CORRECT ANSWERS b) add() (Quiz 1) Which behavior is not specified in the bag ADT? a) remove() b) contains() c) clear() d) sort() CORRECT ANSWERS d) sort() (Quiz 2) Which of the following methods is a good candidate for a core method: a) clear() b) add() c) Contains() d) remove() CORRECT ANSWERS b) add() (Quiz 2) What are the consequences of returning a reference to the bag array in the toArray method? a) the return variable is an alias for the private instance array variable b) the client will have direct access to the private instance array variable c) the client could change the contents of the private instance array variable without using the public access methods d) all of the above CORRECT ANSWERS d) all of the above (Quiz 2) An incomplete definition of a method is called a _____. a) stub b) core method c) fail-safe method d) security problem CORRECT ANSWERS a) stub (Quiz 2) A test driver for the bag add method should check for which one of the following a) an over capacity condition b) printing elements of the bag c) adding elements of the correct type
(Quiz 2) A fixed size array a) has a limited capacity b) can waste memory c) prevents expansion when the bag becomes full d) all of the above CORRECT ANSWERS d) all of the above (Quiz 2) In order to resize an array to accommodate a larger bag, you must a) define an alias that references the original array b) create a new array that is larger than the original array and make the alias reference it c) copy the contents of the original array reference by the alias to the new array and discard the original array d) all of the above CORRECT ANSWERS d) all of the above (Quiz 2) When resizing an array to increase the bag size, if the copy exceeds the maximum memory specified for the computer, the checkCapacity method should a) throw a MaxSizeExceededException b) throw an IllegalStateException c) throw a MaxMemoryExceededException d) return false CORRECT ANSWERS b) throw an IllegalStateException (Quiz 2) Which of the following is an advantage of using an array to implement the ADT bag? a) adding an entry to a bag is fast b) removing a particular entry requires time to locate the entry c) increasing the size of the array requires time to copy its entries d) the client has control over the size of the bag CORRECT ANSWERS a) adding an entry to a bag is fast Which of the following is a disadvantage of using an array to implement the ADT bag? a) adding an entry to a bag is fast b) increasing the size of the array requires time to copy its entries c) removing an unspecified entry from the array is fast d) all of the above CORRECT ANSWERS b) increasing the size of the array requires time to copy its entries