

Computer Science II
Review Questions
Course Introduction
Computer Science II builds upon foundational programming concepts introduced in the first course, emphasizing advanced programming techniques, data structures, and problem-solving strategies. Topics covered include arrays, linked lists, stacks, queues, recursion, sorting and searching algorithms, and an introduction to object-oriented programming. Students gain hands-on experience designing, implementing, testing, and debugging complex programs, while developing the analytical skills necessary to tackle larger and more challenging software development projects. This course prepares students for upper-level computer science courses and provides a solid foundation for computational thinking.
Recommended Textbook
Starting Out with Java From Control Structures through Data Structures 2nd Edition by Tony Gaddis
Available Study Resources on Quizplus
22 Chapters
981 Verified Questions
981 Flashcards
Source URL: https://quizplus.com/study-set/3640 Page 2


Chapter 1: Introduction to Computers and Java
Available Study Resources on Quizplus for this Chatper
42 Verified Questions
42 Flashcards
Source URL: https://quizplus.com/quiz/72352
Sample Questions
Q1) The contents of a variable cannot be changed while the program is running.
A)True
B)False
Answer: False
Q2) This is a cross between human language and a programming language.
A) Pseudocode
B) Java
C) The Java Virtual Machine
D) The compiler
Answer: A
Q3) Java source files end with the .class extension.
A)True
B)False
Answer: False
Q4) These are used to indicate the end of a Java statement.
A) Semicolons
B) Colons
C) Periods
D) Asterisks
Answer: A
To view all questions and flashcards with answers, click on the resource link above. Page 3

Chapter 2: Java Fundamentals
Available Study Resources on Quizplus for this Chatper
53 Verified Questions
53 Flashcards
Source URL: https://quizplus.com/quiz/72353
Sample Questions
Q1) Assuming that pay has been declared a double,the following statement is valid. pay = 2,583.44;
A)True
B)False
Answer: False
Q2) What will be the value of z as a result of executing the following code? int x = 5,y = 28; Float z;
Z = (float)(y / x);
A) 5.60
B) 5.6
C) 3.0
D) 5.0
Answer: D
Q3) Which of the following does not describe a valid comment in Java?
A) Single line comments,two forward slashes - //
B) Multi-line comments,start with /* and end with */
C) Multi-line comments,start with */ and end with /*
D) Documentation comments,any comments starting with /** and ending with */
Answer: C
To view all questions and flashcards with answers, click on the resource link above. Page 4
Chapter 3: Decision Structures
Available Study Resources on Quizplus for this Chatper
52 Verified Questions
52 Flashcards
Source URL: https://quizplus.com/quiz/72354
Sample Questions
Q1) What will be the value of ans after the following code has been executed? int ans = 10;
Int x = 65;
Int y = 55; If (x >= y)
Ans = x + y;
A) 10
B) 120
C) 100
D) No value,there is a syntax error
Answer: B
Q2) When two Strings are compared using the compareTo method,the cases of the two strings are not considered.
A)True
B)False
Answer: False
To view all questions and flashcards with answers, click on the resource link above.

Page 5

Chapter 4: Loops and Files
Available Study Resources on Quizplus for this Chatper
48 Verified Questions
48 Flashcards
Source URL: https://quizplus.com/quiz/72355
Sample Questions
Q1) Given the following statement,which statement will write "Calvin" to the file DiskFile.txt? PrintWriter diskOut = new PrintWriter("DiskFile.txt");
A) System.out.println(diskOut,"Calvin");
B) DiskFile.println("Calvin");
C) PrintWriter.println("Calvin");
D) diskOut.println("Calvin");
Q2) You can use this method to determine whether a file exists.
A) The Scanner class's exists method
B) The File class's exists method
C) The File class's canOpen method
D) The PrintWriter class's fileExists method
Q3) What will be the values of x and y as a result of the following code? int x = 25,y = 8; X += y++;
A) x = 25,y = 8
B) x = 33,y = 8
C) x = 33,y = 9
D) x = 34,y = 9
To view all questions and flashcards with answers, click on the resource link above.

Chapter 5: Methods
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/72356
Sample Questions
Q1) Only constants and variables may be passed as arguments to methods.
A)True
B)False
Q2) The process of breaking a problem down into smaller pieces is called
A) functional decomposition
B) scientific method
C) top-down programming
D) whole-into-part
Q3) When an argument is passed to a method,
A) its value is copied into the method's parameter variable
B) its value may be changed within the called method
C) values may not be passed to methods
D) the method must not assign another value to the parameter that receives the argument
Q4) Which of the following is not a part of the method header?
A) return type
B) method name
C) parentheses
D) semicolon
To view all questions and flashcards with answers, click on the resource link above. Page 7

Chapter 6: A First Look at Classes
Available Study Resources on Quizplus for this Chatper
49 Verified Questions
49 Flashcards
Source URL: https://quizplus.com/quiz/72357
Sample Questions
Q1) Methods that operate on an object's fields are called
A) instance variables
B) instance methods
C) public methods
D) private methods
Q2) When an object is created,the attributes associated with the object are called
A) instance fields
B) instance methods
C) fixed attributes
D) class instances
Q3) A class specifies the ________ and ________ that a particular type of object has.
A) relationships;methods
B) fields;object names
C) fields;methods
D) relationships;object names
Q4) Instance methods do not have the key word static in their headers.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above. Page 8

Chapter 7: A First Look at Gui Applications
Available Study Resources on Quizplus for this Chatper
49 Verified Questions
49 Flashcards
Source URL: https://quizplus.com/quiz/72358
Sample Questions
Q1) You would use this command at the operating system command line to execute the code in the MyApplication class and display the graphic image Logo·jpg as a splash screen.
A) java MyApplication Logo·jpg
B) java -splash:Logo·jpg MyApplication
C) java MyApplication -splash
D) java Logo·jpg -splash:MyApplication
Q2) What will be the result of executing the following statement? panel.setBorder(BorderFactory.createLineBorder(Color.BLUE,5));
A) The JPanel referenced by panel will have a blue line border that is 5 millimeters thick.
B) The JPanel referenced by panel will have a blue line border that is 5 pixels thick.
C) The JPanel referenced by panel will have a blue line border that is 5 characters thick.
D) The JPanel referenced by panel will have a blue line border that is 5 inches thick.
To view all questions and flashcards with answers, click on the resource link above.

Chapter 8: Arrays and the Arraylist Class
Available Study Resources on Quizplus for this Chatper
52 Verified Questions
52 Flashcards
Source URL: https://quizplus.com/quiz/72359
Sample Questions
Q1) If a[] and b[] are two integer arrays,the expression a == b compares the array contents.
A)True
B)False
Q2) The following statement creates an ArrayList object.What is the purpose of the < String > notation? ArrayList< String > arr = new ArrayList< String >();
A) It specifies that only String objects may be stored in the ArrayList object.
B) It specifies that the get method will return only String objects.
C) It specifies that String objects may not be stored in the ArrayList object.
D) It specifies that everything stored in the ArrayList object will be converted to a String.
Q3) You can use this ArrayList class method to insert an item at a specific location in an ArrayList.
A) insert
B) add
C) store
D) putItem
To view all questions and flashcards with answers, click on the resource link above.

Chapter 9: A Second Look at Classes and Objects
Available Study Resources on Quizplus for this Chatper
40 Verified Questions
40 Flashcards
Source URL: https://quizplus.com/quiz/72360
Sample Questions
Q1) When an object is passed as an argument,it is actually a reference to the object that is passed.
A)True B)False
Q2) An instance of a class does not have to exist in order for values to be stored in a class's static fields.
A)True B)False
Q3) When an object reference is passed to a method,the method may change the values in the object.
A)True
B)False
Q4) The key word this is the name of a reference variable that an object can use to refer to itself.
A)True B)False
Q5) Enum constants have a toString method. A)True B)False
To view all questions and flashcards with answers, click on the resource link above. Page 11

Chapter 10: Text Processing and More About Wrapper
Classes
Available Study Resources on Quizplus for this Chatper
49 Verified Questions
49 Flashcards
Source URL: https://quizplus.com/quiz/72361
Sample Questions
Q1) To convert the string,str = "285.74" to a double,use the following statement.
A) double x = str;
B) double x = Double.parseDouble(str);
C) double x = Double.Double(str);
D) double x = str,Double.parseDouble;
Q2) What would be the results of executing the following code? StringBuilder str = new StringBuilder(12);
Str)append("The cow");
Str)append(" jumped over the ");
Str)append("moon.");
A) The program would crash
B) str would reference "The cow jump"
C) str would reference "The cow jumped over the "
D) str would reference "The cow jumped over the moon."
Q3) If a string has more than one character used as a delimiter,we must write a loop to determine the tokens,one for each delimiter character.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above. Page 12
Chapter 11: Inheritance
Available Study Resources on Quizplus for this Chatper
49 Verified Questions
49 Flashcards
Source URL: https://quizplus.com/quiz/72362
Sample Questions
Q1) When an "is a" relationship exists between objects,it means that the specialized object has
A) some of the characteristics of the general class,but not all,plus additional characteristics.
B) some of the characteristics of the general object,but not all.
C) none of the characteristics of the general object.
D) all the characteristics of the general object,plus additional characteristics.
Q2) In a class hierachy
A) the more general classes are toward the bottom of the tree and the more specialized are toward the top.
B) the more general classes are toward the top of the tree and the more specialized are toward the bottom.
C) the more general classes are toward the left of the tree and the more specialized are toward the right.
D) the more general classes are toward the right of the tree and the more specialized are toward the left.
To view all questions and flashcards with answers, click on the resource link above.

13

Chapter 12: Exceptions and Advanced File Io
Available Study Resources on Quizplus for this Chatper
46 Verified Questions
46 Flashcards
Source URL: https://quizplus.com/quiz/72363
Sample Questions
Q1) In a try/catch construct,after the catch statement is executed
A) the program returns to the statement following the statement in which the exception occurred.
B) the program terminates.
C) the program resumes at the statement that immediately follows the try/catch construct.
D) the program resumes at the first statement of the try statement.
Q2) If,within one try statement you want to have catch clauses that catch exceptions of the following types,in which order should they appear in your program? (1)Throwable (2)Exception
(3)RuntimeException
(4)NumberFormatException
A) 4,3,2,1
B) 2,3,1,4
C) 4,1,3,2
D) 3,1,2,4
Q3) The throws clause causes an exception to be thrown.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above.
Page 14

Chapter 13: Advanced Gui Applications
Available Study Resources on Quizplus for this Chatper
46 Verified Questions
46 Flashcards
Source URL: https://quizplus.com/quiz/72364
Sample Questions
Q1) If the combo box addressBox contains a list of strings,why is the returned value of getSelectedItem method in the following code cast to String? String selectedAddress; SelectedAddress = (String)addressBox.getSelectedItem();
A) This is not necessary.
B) Because the syntax of the method requires it.
C) It makes the program more readable
D) Because the return type of the method is an Object.
Q2) A label's preferred size is determined only by calling the setPreferredSize method. A)True
B)False
Q3) Which of the following is not a class used in constructing a menu system?
A) JMenuItem
B) JCheckBoxMenuItem
C) JComboBoxMenuItem
D) JRadioButtonMenuItem
Q4) You can create a label with an image,or with both an image and text.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above.

Chapter 14: Applets and More
Available Study Resources on Quizplus for this Chatper
39 Verified Questions
39 Flashcards
Source URL: https://quizplus.com/quiz/72365
Sample Questions
Q1) The following getAudioClip()method returns an object that will load the sound file and assign the location of that file to clip which can then be used to call methods that may play the sound file one or more times: Audioclip clip = getAudioClip(getDocumentBase(),"mysound.wav");
A)True
B)False
Q2) Which of the following will load the applet,TestApplet?
A) < applet code="TestApplet.class" width=200 height=50 >< /applet >
B) < applet code=TestApplet.class width=200 height=50 >< /applet >
C) < load code="TestApplet.class" width=200 height=50 >< /load >
D) < load code=TestApplet.class width=200 height=50 >< /load >
Q3) In an HTML document,the tags
A) instruct the Web browser how to format the text.
B) instruct the Web browser where to place images.
C) instruct the Web browser what to do when the user clicks on a link.
D) All of the above
Q4) Some browsers do not directly support the Swing classes of applets.
A)True
B)False
To view all questions and flashcards with answers, click on the resource link above. Page 16

Chapter 15: Recursion
Available Study Resources on Quizplus for this Chatper
34 Verified Questions
34 Flashcards
Source URL: https://quizplus.com/quiz/72366
Sample Questions
Q1) The actions that the JVM must perform any time a method is called is called
A) stack frame.
B) overhead.
C) housekeeping.
D) method calls.
Q2) A problem can be solved recursively if it can be broken down into successive smaller problems that are identical to the overall problem.
A)True
B)False
Q3) Look at the following pseudocode algorithm. algorithm Test14(int x)
If (x < 8)
Return (2 * x)
Else
Return (3 * Test14(x - 8)+ 8)
End Test14
What is the depth of Test14(16)?
A) 0
B) 1
C) 2
D) 3
To view all questions and flashcards with answers, click on the resource link above. Page 17

Chapter 16: Sorting, Searching, and Algorithm Analysis
Available Study Resources on Quizplus for this Chatper
46 Verified Questions
46 Flashcards
Source URL: https://quizplus.com/quiz/72367
Sample Questions
Q1) The binary search algorithm
A) cannot be used to search an array that is not sorted B) does twice as much work as sequential search on the average case C) must be written using recursion D) is slower than sequential search when the item being searched for is not in the array
Q2) If lower is the first subscript in a contiguous portion of an array,and upper is the last subscript,then the array item in the middle of that array portion is at subscript
A) (lower + upper)/2
B) (lower - upper./2
C) lower + upper/2
D) (upper - lower./2
Q3) The two criteria most often used to measure the efficiency of an algorithm are A) efficiency and style
B) space and time
C) style and time
D) execution and speed
To view all questions and flashcards with answers, click on the resource link above.

Chapter 17: Generics
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/72368
Sample Questions
Q1) One of the advantages of using generics is
A) that more type problems can be uncovered at compile-time rather than at run time
B) that programs that use generics are smaller when translated to byte code
C) that program that use generics execute faster than programs that do not
D) that programs that use generic code require less effort in design and development
Q2) Which of the following statements are true?
A) The compiler translates generic code by replacing generic types with Object,or with the upper bounds of those types.
B) The compiler often has to insert type casts into code that results from translating generic ode
C) Generic types do not exist at the byte code level
D) All of the above
Q3) The declaration
ArrayList< int > aL = new ArrayList< int >();
A) allows the programmer to create an ArrayList that holds integer types
B) compiles correctly,but causes an exception to be thrown at run time
C) causes a compile-time error
D) compiles and runs correctly,but is not recommended
To view all questions and flashcards with answers, click on the resource link above.
19

Chapter 18: Collections
Available Study Resources on Quizplus for this Chatper
50 Verified Questions
50 Flashcards
Source URL: https://quizplus.com/quiz/72369
Sample Questions
Q1) The default implementation of hashCode in Java returns
A) a value determined from the class type of the object
B) a value derived from the memory address of the object
C) a value determined from the values of the fields in the object
D) None of the above
Q2) Comparable
A) specifies a single method,compareTo
B) specifies three methods,compareTo,compare,and equals
C) specifies two methods,compare and equals
D) specifies two methods,compare and compareTo
Q3) An object that is used to retrieve objects from a collection is called
A) an iterator
B) a collector
C) an accessor
D) All of the above
Q4) Which of the following is true?
A) Both the Set and List interfaces extend the Collection interface
B) Both the Set and Map interfaces extend the Collection interface
C) Both the List and Map interfaces extend the Collection interface
D) None of the above
To view all questions and flashcards with answers, click on the resource link above. Page 20

Chapter 19: Array-Based Lists
Available Study Resources on Quizplus for this Chatper
20 Verified Questions
20 Flashcards
Source URL: https://quizplus.com/quiz/72370
Sample Questions
Q1) The int indexOf(Object o)method of the List interface
A) searches a list for the occurrence of an object and returns its index
B) adds an object to a list and returns the index of the newly added object
C) uses binary search to locate the given object,and then returns its index
D) None of the above
Q2) Assume an array-based list implemented by a class that uses the fields
String [ ] list; int nElements;
to represent the array of elements,and the number of elements currently stored.Show the code for a method String set(int index,String str)that sets the element at the given index to str and returns the element previously stored there.
Q3) Assume an array-based list implemented by a class that uses the fields
String [ ] list; int nElements;
to represent the array of elements,and the number of elements currently stored.Show the code for a method String remove(int index)that removes and returns the element at the given index.The method should throw an appropriately named exception if it cannot return the requested element.
To view all questions and flashcards with answers, click on the resource link above. Page 21

Chapter 20: Linked Lists
Available Study Resources on Quizplus for this Chatper
36 Verified Questions
36 Flashcards
Source URL: https://quizplus.com/quiz/72371
Sample Questions
Q1) To remove a node with index 0 from a linked list, A) just move the head reference one node forward
B) set the head reference to null
C) set a reference r to the head of the list,and then set r to null D) throw an exception,because no list has a node with index 0
Q2) The tail of a list
A) is an instance of a class that implements the ListTail interface
B) is what you get when take a list and remove its head
C) is a synchronized subclass of the LinkedList class
D) None of the above
Q3) In Java,the first node in a list has index
A) -1
B) 0
C) 1
D) 2
Q4) In a linked list,the successor of a node X
A) may not exist
B) is the node that comes after X,and it always exists
C) is the last node in the list
D) is the node whose index is one greater than the index of X
Page 22
To view all questions and flashcards with answers, click on the resource link above.

Chapter 21: Stacks and Queues
Available Study Resources on Quizplus for this Chatper
36 Verified Questions
36 Flashcards
Source URL: https://quizplus.com/quiz/72372
Sample Questions
Q1) A stack is a container that allows elements to be stored and removed
A) in a last-in-first-out fashion
B) in a first-in-first-out fashion
C) last-in-last-out fashion
D) according to priority
Q2) A queue based on a linked list uses the following code Class Node{ String element; Node next;
Node (String el,Node n){ Element = el;
Next = n; } } Node front,rear;
What is the right code for a constructor for such a linked list class?
A) element = el;next = n;
B) front = rear;
C) front = null;rear = null;
D) front = element;rear = front;
To view all questions and flashcards with answers, click on the resource link above.
Page 23

Chapter 22: Binary Trees, Avl Trees, and Priority Queues
Available Study Resources on Quizplus for this Chatper
45 Verified Questions
45 Flashcards
Source URL: https://quizplus.com/quiz/72373
Sample Questions
Q1) An empty binary tree has height
A) -1
B) 0
C) 1
D) None of the above: the height of an empty binary tree is not defined.
Q2) A binary tree is a collection of nodes in which
A) each node has at most one predecessor and at most one successor
B) each node has at most one predecessor and exactly two successors
C) each node has at most one predecessor and at most two successors
D) each node has at least one predecessor and at most two successors
Q3) To find the minimum element stored in a heap
A) you should start at the root,and then keep passing from each node to its left child until you come to a node with no left child
B) you should start at the root,and then keep passing from each node to its right child until you come to a node with no right child
C) you should look at the root of the binary tree
D) you need to examine every node,and then pick the one with the least value
To view all questions and flashcards with answers, click on the resource link above. Page 24