

Computer Science II
Test Preparation
Course Introduction
Computer Science II builds upon the foundational principles introduced in introductory computer science courses, delving deeper into programming concepts, data structures, and algorithmic problem-solving. Topics typically include recursion, object-oriented programming, linked lists, stacks, queues, trees, and sorting and searching algorithms. Students develop advanced programming skills through hands-on projects, enhancing their ability to design, implement, and analyze efficient solutions to complex computational problems. This course prepares students for further study in computer science and related fields by reinforcing best practices in software development and critical thinking.
Recommended Textbook
Absolute Java 5th Edition by Walter Savitch
Available Study Resources on Quizplus
20 Chapters
758 Verified Questions
758 Flashcards
Source URL: https://quizplus.com/study-set/3975

Page 2
Chapter 1: Getting Started
Available Study Resources on Quizplus for this Chatper
46 Verified Questions
46 Flashcards
Source URL: https://quizplus.com/quiz/79864
Sample Questions
Q1) What is the output of the following Java statements? //String method examples
String str = "Java Programming!"; System.out.println(str.equals("Java Programming!")); System.out.println(str.toLowerCase()); System.out.println(str.toUpperCase()); System.out.println(str.substring(5,8)); System.out.println(str.lastIndexOf("m"));
A)True
B)False
Answer: true
Q2) The escape sequence the represents the new-line character is:
A)\r
B)\t
C)\n
D)\\

Answer: C
To view all questions and flashcards with answers, click on the resource link above. Page 3

Chapter 2: Console Input and Output
Available Study Resources on Quizplus for this Chatper
29 Verified Questions
29 Flashcards
Source URL: https://quizplus.com/quiz/79862
Sample Questions
Q1) What does it mean to prompt the user?
Answer: Prompting the user means to display a meaningful message to the user asking for some type of input.An example of prompting the user would be displaying a JOptionPane to ask the user to input their name.
Q2) Explain the significance of the pattern string used by the DecimalFormat object,and give an example of a valid pattern.
Answer: The pattern string represents the format in which the number passed to the DecimalFormat object is formatted.The pattern can either specify the exact number of digits before and after the decimal,or it can specify the minimum numbers of digits.The character '0' is used to represent a required digit and the character '#' is used to represent optional digits.Valid patterns include: "0.00","#0.0##".
Q3) Write ONE Java statement to display your first and last name on two separate lines. Answer: System.out.print("Wally\nWonders");
Q4) The printf method can be used to output multiple formatted values.
A)True
B)False
Answer: True
To view all questions and flashcards with answers, click on the resource link above. Page 4
Chapter 3: Flow of Control
Available Study Resources on Quizplus for this Chatper
43 Verified Questions
43 Flashcards
Source URL: https://quizplus.com/quiz/79861
Sample Questions
Q1) An if selection statement executes if and only if:
A)the Boolean condition evaluates to false.
B)the Boolean condition evaluates to true.
C)the Boolean condition is short-circuited.
D)none of the above.
Answer: B
Q2) A ___________ statement terminates the current iteration of a loop.
A)Break
B)Continue
C)Switch
D)Assert

Answer: B
Q3) Discuss the rules Java follows when evaluating expressions.
Answer: First,Java binds operands with operators by fully parenthesizes the expression using precedence and associativity rules. Next,Java evaluates expressions from left to right. Finally,if an operator is waiting for other operands to be evaluated,then that operator is evaluated as soon as its operands have been evaluated.
To view all questions and flashcards with answers, click on the resource link above.
Page 5

Chapter 4: Defining Classes I
Available Study Resources on Quizplus for this Chatper
44 Verified Questions
44 Flashcards
Source URL: https://quizplus.com/quiz/79860
Sample Questions
Q1) A _________ states what is assumed to be true when the method is called.
A)prescript
B)postscript
C)precondition
D)postcondition
Q2) Discuss the importance of accessor and mutator methods and how they apply to the abstraction concept.
Q3) The modifier private means that an instance variable can be accessed by name outside of the class definition.
A)True
B)False
Q4) Add two constructors to the Appointment class created in question #9.Include a default constructor and a constructor to initialize an Appointment to suitable arguments.
Q5) When you give a command to run a Java program,the runtime system invokes the class constructor.
A)True
B)False
Q6) Discuss the public and private modifiers in context of methods and instance variables.
Page 6
To view all questions and flashcards with answers, click on the resource link above.

Chapter 5: Defining Classes Ii
Available Study Resources on Quizplus for this Chatper
46 Verified Questions
46 Flashcards
Source URL: https://quizplus.com/quiz/79859
Sample Questions
Q1) Wrapper classes provide a class type corresponding to each of the primitive types so that you can have class types that behave somewhat like primitive types.
A)True
B)False
Q2) Converting from a value of primitive type to a corresponding object of its associated wrapper class is called:
A)Boxing
B)Unboxing
C)Converting
D)Reinstantiating
Q3) The Math method that returns the nearest whole number that is greater than or equal to its argument is:
A)round
B)ceil
C)floor
D)all of the above
Q4) Write a Java method that returns true if and only if a character is a digit or a letter.The method should display appropriate feedback to the console.
To view all questions and flashcards with answers, click on the resource link above.

Chapter 6: Arrays
Available Study Resources on Quizplus for this Chatper
47 Verified Questions
47 Flashcards
Source URL: https://quizplus.com/quiz/79858
Sample Questions
Q1) The individual variables that together make up the array are referred to as:
A)indexed variables
B)subscripted variables
C)elements of the array
D)all of the above
Q2) You can only use array indexed variables as arguments to methods.
A)True
B)False
Q3) Consider the following array: What is the value of myArray[myArray[1] - myArray[0]]
A)7
B)9
C)-3
D)6
Q4) Write a Java method that takes an integer array as a formal parameter and returns the sum of integers contained within the array.
Q5) Write a Java statement that declares and creates an array of Strings named Breeds.Your array should be large enough to hold the names of 100 dog breeds.
Q6) How are arrays tested to see if they contain the same contents?
To view all questions and flashcards with answers, click on the resource link above. Page 8

Chapter 7: Inheritance
Available Study Resources on Quizplus for this Chatper
43 Verified Questions
43 Flashcards
Source URL: https://quizplus.com/quiz/79857
Sample Questions
Q1) You may substitute the keyword this for super()to call a constructor of the derived class.
A)True
B)False
Q2) What is a "has a" relationship?
Q3) The keyword extends indicates:
A)encapsulation
B)polymorphism
C)inheritance
D)none of the above
Q4) If the final modifier is added to the definition of a method,this means:
A)The method may be redefined in the derived class.
B)The method may be redefined in the sub class.
C)The method may not be redefined in the derived class.
D)None of the above.
Q5) Explain the difference between method overloading and method overriding.
Q6) Write Java statements that compares Objects,O1 and O2,using the getClass()method.
Q7) Define a base class to represent a Clock.Your class should have instance variables for hours,minutes and seconds.
To view all questions and flashcards with answers, click on the resource link above. Page 9

Chapter 8: Console Input and Output
Available Study Resources on Quizplus for this Chatper
43 Verified Questions
43 Flashcards
Source URL: https://quizplus.com/quiz/79856
Sample Questions
Q1) If you choose to use the method clone in your code,you must ___________ the clone method.
A)overload
B)encapsulate
C)override
D)protect
Q2) What is an abstract method?
Q3) Downcasting should be used only in situations where it makes sense.
A)True
B)False
Q4) Write a decision statement to determine if an object should be downcast.
Q5) Derive a class named Tennis Shoes from the base class created in number 9 above.
Q6) ____________ refers to the process of associating a method definition with a method invocation.
A)Binding
B)Encapsulation
C)Inheritance
D)Polymorphism
Q7) What are the advantages of polymorphism?
To view all questions and flashcards with answers, click on the resource link above. Page 10
Q8) Why should the instanceOf operator be used in conjunction with downcasting?

Chapter 9: Exception Handling
Available Study Resources on Quizplus for this Chatper
45 Verified Questions
45 Flashcards
Source URL: https://quizplus.com/quiz/79855
Sample Questions
Q1) If you were going to catch an exception of type Exception,where should this catch block be placed within your code?
Q2) Exceptions that are subject to the catch or declare rule are called:
A)Checked exceptions
B)Unchecked exceptions
C)Fatal exceptions
D)All of the above
Q3) Every exception class is an ancestor of the class Exception.
A)True
B)False
Q4) If a method does not catch an exception,then it must at least warn programmers that any invocation of the method might possibly throw an exception.This warning is called a/an:
A)Exception handler
B)Throws clause
C)Try block
D)Catch block
Q5) What is the purpose of the finally block?
Q6) Revise the program in number 8 above to use a try/catch block to handle the IOException.
To view all questions and flashcards with answers, click on the resource link above. Page 11

Chapter 10: File IO
Available Study Resources on Quizplus for this Chatper
46 Verified Questions
46 Flashcards
Source URL: https://quizplus.com/quiz/79874
Sample Questions
Q1) The class ObjectInputStream contains all of the following methods except:
A)readLine()
B)readChar()
C)readObject()
D)readInt()
Q2) Use the output stream to the file autos.txt created above in number 2 to write the line "Mercedes" to the file.
Q3) In Java,when you open a text file you should account for a possible:
A)FileNotFoundException
B)FileFullException
C)FileNotReadyException
D)all of the above
Q4) Write a Java statement to create an input stream to a file named autos.txt.Use the BufferedReader class.
Q5) An ___________ allows data to flow into your program.
A)input stream
B)output stream
C)file name
D)all of the above
Q6) Explain the differences between a text file,an ASCII file and a binary file.
To view all questions and flashcards with answers, click on the resource link above. Page 12

Chapter 12: Uml and Patterns
Available Study Resources on Quizplus for this Chatper
22 Verified Questions
22 Flashcards
Source URL: https://quizplus.com/quiz/79872
Sample Questions
Q1) In a UML class diagram,the sharp (#)indicates:
A)public access
B)protected access
C)private access
D)package access
Q2) Any construct that allows you to cycle through all the items in a container is an iterator.
A)True
B)False
Q3) The arrowheads in an inheritance diagram point:
A)North
B)South
C)East
D)West
Q4) The Adaptor pattern transforms one class into a different class without changing the underlying class.
A)True
B)False
Q5) Draw a UML class diagram for a class that represents a savings account.
Q6) Define pseudocode.
To view all questions and flashcards with answers, click on the resource link above. Page 13

Chapter 13: Interfaces and Inner Classes
Available Study Resources on Quizplus for this Chatper
32 Verified Questions
32 Flashcards
Source URL: https://quizplus.com/quiz/79871
Sample Questions
Q1) A common use of inner classes is :
A)clean up
B)set up
C)helper
D)all of the above
Q2) An interface specifies the headings and definitions for methods that must be defined in any class that implements the interface.
A)True
B)False
Q3) An interface and all of its method headings are normally declared to be:
A)public
B)private
C)protected
D)package access
Q4) An interface can contain defined constants as well as method headings or instead of method headings.
A)True
B)False
Q5) Why does Java only allow the inheritance of only one base class?
Q6) What are the semantics of the Comparable interface?
To view all questions and flashcards with answers, click on the resource link above. Page 14

Chapter 14: Generics and the Arraylist Class
Available Study Resources on Quizplus for this Chatper
31 Verified Questions
31 Flashcards
Source URL: https://quizplus.com/quiz/79870
Sample Questions
Q1) ArrayList objects do not have the array square-bracket notation.
A)True
B)False
Q2) The keyword ___________ can be used to place a bound on a type parameter.
A)Implements
B)Inherits
C)Encapsulates
D)Extends
Q3) When using ArrayLists the method _______ can be used to save memory:
A)trimToSize()
B)trimDown()
C)trimOff()
D)None of the above
Q4) A class obtained from a generic class by plugging in a type for the type parameter is said to ________ the generic class.
A)Inherit
B)Encapsulate
C)Instantiate
D)None of the above
Q5) What are the three main disadvantages of an ArrayList?
To view all questions and flashcards with answers, click on the resource link above. Page 15

Chapter 15: Linked Data Structures
Available Study Resources on Quizplus for this Chatper
43 Verified Questions
43 Flashcards
Source URL: https://quizplus.com/quiz/79869
Sample Questions
Q1) Forgetting to set the reference instance variable of the last node in a linked list to null will cause a logic error.
A)True
B)False
Q2) Create a generic Node class to represent the linked list depicted in your diagrams above.
Q3) A stack cannot be represented as a linked list.
A)True
B)False
Q4) What is the function of the variable head when used with a linked list? What is the data type of the head variable?
Q5) Redraw the diagram created in number 4 above after deleting the head node.
Q6) A queue is a last-in/first-out structure.
A)True
B)False
Q7) A linked data structure contains nodes and links.
A)True
B)False
Q8) following values in the given order: 7,10,5,12,1,3,9.
To view all questions and flashcards with answers, click on the resource link above. Page 16

Chapter 16: Collections and Iterators
Available Study Resources on Quizplus for this Chatper
44 Verified Questions
44 Flashcards
Source URL: https://quizplus.com/quiz/79868
Sample Questions
Q1) Write a Java statement to create a vector with initial capacity of 50.
Q2) Write a method named displayList()that has one parameter of type Vector and has a return value of void.The method uses an iterator to display the contents of the Vector.
Q3) Create a for loop to initially set the values of the vector created in number 1 above to the value of negative 1.0.
Q4) How can one retrieve all the values of a HashMap object?
Q5) The method ___________ can be used to determine the number of elements in an ArrayList.
A)length()
B)vectorLength()
C)size()
D)vectorSize()
Q6) What is the difference between a vector's size and a vector's capacity?
Q7) The difference between the List<T> interface and the Set<T> interface is that the Set<T> interface does not impose an order on its unique elements.
A)True
B)False
Q8) Write a Java statement to resize the resulting vector in number 2 above to 100.
To view all questions and flashcards with answers, click on the resource link above. Page 17

Chapter 17: Swing I
Available Study Resources on Quizplus for this Chatper
37 Verified Questions
37 Flashcards
Source URL: https://quizplus.com/quiz/79867
Sample Questions
Q1) A _____________ is an object that is a simple container class that groups other objects.
A)JPanel
B)JMenu
C)JButton
D)JTextArea
Q2) The JFrame method setVisible()takes one argument of type:
A)byte
B)boolean
C)int
D)short
Q3) A programming style that uses a signal and response approach to programming is called:
A)Object Oriented Programming
B)Structured Programming
C)Event-driven Programming
D)Bottom-up Programming
Q4) Write Java statements to add the menu created in number 7 above to the menu bar.
Q5) Write Java statements to add menu items named "Circle","Square",and "Rectangle" to the menu created in number 7 above.
To view all questions and flashcards with answers, click on the resource link above. Page 18

Chapter 18: Swing II
Available Study Resources on Quizplus for this Chatper
31 Verified Questions
31 Flashcards
Source URL: https://quizplus.com/quiz/79866
Sample Questions
Q1) The Insets class is in the package ______________.
A)java.awt
B)javax.swing
C)java.util
D)java.lang
Q2) A view port shows only part of the text at one time.
A)True
B)False
Q3) When the user clicks any of the three standard JFrame buttons,a ___________ is generated.
A)window listener
B)window event
C)window activator
D)window deactivator
Q4) The paint method of the Graphics class can only be used with Applets.
A)True
B)False
Q5) The dispose method of the JFrame class terminates a Java program.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above. Page 19
Chapter 19: Java Never Ends
Available Study Resources on Quizplus for this Chatper
18 Verified Questions
18 Flashcards
Source URL: https://quizplus.com/quiz/79865
Sample Questions
Q1) What method in the Thread class is responsible for pausing a thread for a specific amount of milliseconds?
A)pause()
B)sleep()
C)hang()
D)kill()
Q2) ____________ means that an object has an identity that extends beyond one session.
A)Event handling
B)Introspection
C)Persistence
D)None of the above
Q3) Discuss the components of the JavaBean model.
Q4) An InterruptedException is a checked exception.
A)True
B)False
Q5) What is a JavaBean?
Q6) SQL stands for Structured Query Language.
A)True
B)False

Page 20
To view all questions and flashcards with answers, click on the resource link above.

Chapter 11: Recursion
Available Study Resources on Quizplus for this Chatper
43 Verified Questions
43 Flashcards
Source URL: https://quizplus.com/quiz/79873
Sample Questions
Q1) Write an iterative method to compute the factorial of a number.
Q2) What are two factors that contribute to the inefficiency of some recursive solutions?
Q3) All recursive methods have a/an ____________ equivalent method.
A)Iterative
B)Selective
C)Inherited
D)None of the above
Q4) The order of magnitude of the binary search algorithm is:
A)linear
B)exponential
C)logarithmic
D)quadratic
Q5) Write an iterative method to print a string backwards.
Q6) Explain how the binary search works.
Q7) All recursive methods must have a/an:
A)starting case
B)intermediate case
C)stopping case
D)none of the above
To view all questions and flashcards with answers, click on the resource link above. Page 21

Chapter 20: Applets
Available Study Resources on Quizplus for this Chatper
25 Verified Questions
25 Flashcards
Source URL: https://quizplus.com/quiz/79863
Sample Questions
Q1) Applets do not normally have constructors.The ___________ method performs the initialization of instance variables.
A)setJMenuBar()
B)init()
C)paint()
D)close()
Q2) HTML is case sensitive.
A)True
B)False
Q3) URL stands for:
A)Unified Resource Locator
B)Uniform Reader Locator
C)Uniform Resource Locator
D)Uniform Resource Language
Q4) Images can be embedded within HTML pages.
A)True
B)False
Q5) HTML is part of the Java language.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above. Page 22