

Computer Science I
Mock Exam
Course Introduction
Computer Science I is an introductory course designed to provide students with a foundational understanding of computer programming and problem-solving techniques. Emphasizing core concepts such as variables, control structures, functions, data types, and basic algorithms, the course teaches students how to design, write, test, and debug programs, typically using a high-level programming language such as Python, Java, or C++. Through hands-on practice and projects, students develop logical reasoning and computational thinking skills essential for further study in computer science and related fields.
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) Write a Java statement to determine the length of a string variable called input.Store the result in an integer variable called strLength.
Answer: int strLength = input.length();
Q2) In Java,Strings are immutable objects.Immutable objects can be changed.
A)True
B)False
Answer: False
Q3) To mark a block comment for inclusion in the Javadoc documentation,the block must be delimited by:
A)/** */
B)*/* */
C)**/ /*
D)**/ */

Answer: A
Q4) Applets were designed to run as stand-alone applications.
A)True
B)False
Answer: False
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) If a hyphen is added after the % in a format specifier,the output will be _________.
A)Left justified
B)Right justified
C)Centered
D)None of the above

Answer: A
Q2) The Scanner class has a method next that allows an entire line of string text to be read.
A)True
B)False Answer: False
Q3) Echoing input is good programming practice because it can reveal problems in the input.
A)True
B)False Answer: True
Q4) Write a Java statement to display your name in the console window. Answer: System.out.println("Wally Wonders");
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) The association of operands with operators is called ______________.
A)assignment
B)precedence
C)binding
D)lexicographic ordering
Answer: C
Q2) An empty statement is defined as a loop that runs forever.
A)True
B)False
Answer: False
Q3) The controlling expression for a switch statement includes all of the following types except:
A)char
B)int
C)byte
D)double

Answer: D
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) The parameter this refers to
A)instance variables
B)local variables
C)global variables
D)the calling object
Q2) In Java,a block is delimited by:
A)( )
B)/* */
C)" "
D){ }
Q3) A set method is:
A)an accessor method
B)a mutator method
C)a recursive method
D)none of the above
Q4) Write a Java class that represents a Student with instance variables name,id,and gpa.Include constructors,accessor,mutator and any facilitator methods you may need.
Q5) Discuss the public and private modifiers in context of methods and instance variables.
To view all questions and flashcards with answers, click on the resource link above. Page 6

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) 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
Q2) The String class is a mutable class.
A)True
B)False
Q3) Only ______ copy/copies of a static variable are available to objects of a class.
A)one
B)two
C)three
D)none of the above
Q4) You should avoid the use of null as an argument to a method.
A)True
B)False
Q5) Does an object created with a copy constructor reference the same memory location that the original object references? Explain.
To view all questions and flashcards with answers, click on the resource link above. Page 7

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) Write a complete Java console application that prompts the user for a series of quiz scores.The user should type -1 to signify that the input of quiz scores is complete.Your program should then average the scores and display the result back to the user.
Q2) The name of the sorting algorithm that locates the smallest unsorted value in an array and places it in the next sorted position of the array is called:
A)bubble sort
B)merge sort
C)radix sort
D)selection sort
Q3) Declare and create a 10 x 10 multidimensional array of doubles.
Q4) What is the output of the following code? int[] numbers = new int[10]; for(int i=0; i < numbers.length; ++i) numbers[i] = i * 2; for(int i=0; i < numbers.length; ++i) System.out.print(numbers[i] + " "); System.out.println();
Q5) Initialize the array created in number 11 above to -1.0.
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) A constructor for a derived class begins with an invocation of a constructor for the base class.
A)True
B)False
Q2) 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.
Q3) A base class is synonymous with a:
A)Child class
B)Parent class
C)Derived class
D)Sub class
Q4) What does the instanceof operator do?
Q5) A derived class is also called a
A)sub class
B)super class
C)base class
D)all of the above

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

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) Why should the instanceOf operator be used in conjunction with downcasting?
Q2) __________ refers to the ability to associate many meanings to one method name by means of the late binding mechanism.
A)Inheritance
B)Encapsulation
C)Polymorphism
D)None of the above
Q3) An abstract class is a class that has some methods without complete definitions.
A)True
B)False
Q4) Override the clone method inherited in the Dress Shoes class created in number 10 above.
Q5) Early binding enables the compiler to be more efficient.
A)True
B)False
Q6) Override the clone method inherited in the Tennis Shoes class created in number 11 above.
Q7) Derive a class named Tennis Shoes from the base class created in number 9 above.
Q9) Explain the difference between early and late binding. Page 10
Q8) Write a decision statement to determine if an object should be downcast.
To view all questions and flashcards with answers, click on the resource link above. Page 11

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) What is the purpose of the method getMessage()when used with exception handling?
Q2) Methods that process String arguments as if they were numbers could possibly throw a/an _________ exception.
A)NumberFormatException
B)NullPointerException
C)both a and b
D)none of the above
Q3) Define an exception class called NegativeNumberException.The class should have a constructor with no parameters.If an exception is thrown with this zero-argument constructor,getMessage should return "Negative Number Not Allowed!" The class should also have a constructor with a single parameter of type String.If an exception is thrown with this constructor,then getMessage returns the value that was used as an argument to the constructor.
Q4) Which circumstance is an exception to the catch or declare rule?
A)Exceptions that result from errors of some sort.
B)Exceptions that are descendents of the class RuntimeException.
C)Both A and B
D)None of the above
Q5) Use a catch block to display the exception thrown in number two above.
Q6) Should an application catch objects of type Error?
To view all questions and flashcards with answers, click on the resource link above. Page 12

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 methods of the scanner class do not behave the same when reading from a text file as they do when used to read from the keyboard.
A)True
B)False
Q2) The scanner class has a series of methods that checks to see if there is any more well-formed input of the appropriate type.These methods are called __________ methods:
A)nextToken
B)hasNext
C)getNext
D)testNext
Q3) The method __________ from the File class forces a physical write to the file of any data that is buffered.
A)close()
B)flush()
C)writeUTF()
D)writeObject()
Q4) What happens when the method close is invoked on a stream?
Q5) 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 13

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) UML was designed to be used with structured programming methodology.
A)True
B)False
Q2) A container is a class whose objects hold multiple pieces of data.
A)True
B)False
Q3) The arrowheads in an inheritance diagram point:
A)North
B)South
C)East
D)West
Q4) In a UML class diagram,the plus (+)indicates:
A)public access
B)protected access
C)private access
D)package access
Q5) Pseudocode is a mixture of programming language and English.
A)True
B)False
Q6) Draw a UML class diagram for a class that represents a sphere.
Page 14
To view all questions and flashcards with answers, click on the resource link above.
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) If an inner class contains non static members,then the class name must be modified by the keyword:
A)Final
B)Static
C)Void
D)Protected
Q2) A class may only implement one interface.
A)True
B)False
Q3) Why does Java only allow the inheritance of only one base class?
Q4) The compiler and the run-time system enforces semantics on the Comparable interface.
A)True
B)False
Q5) What are two advantages to using inner classes?
Q6) In Java,a derived class can have ________ base class(es).
A)one
B)two
C)three
D)there is no limit

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

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) An ArrayList object has a fixed size.
A)True
B)False
Q2) Write a Java statement to create an ArrayList to hold 25 integers.
Q3) The Java standard libraries have a class named ___________ that behaves almost exactly the same as the class ArrayList.
A)Array
B)Container
C)Vector
D)All of the above
Q4) When using ArrayLists the method _______ can be used to save memory:
A)trimToSize()
B)trimDown()
C)trimOff()
D)None of the above
Q5) A for loop is an enhanced loop.
A)True
B)False
Q6) What are the three main disadvantages of an ArrayList?
Q7) What is the base type of the ArrayList defined in question number 2?
To view all questions and flashcards with answers, click on the resource link above. Page 16

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) Create a generic Node class to represent the linked list depicted in your diagrams above.
Q2) following values in the given order: 7,10,5,12,1,3,9.
Q3) A linked data structure contains nodes and links.
A)True
B)False
Q4) To use the Java Iterator Interface you must import the ____________ package.
A)java.tools
B)java.linkedlist
C)java.iterator
D)java.util
Q5) Given the Node class created in number 6 above,write Java statements to delete a node from the beginning of the list.
Q6) If the head instance variable of a linked list contains a reference to null,this means the list is:
A)full
B)empty
C)lost
D)none of the above
Q7) What is the binary search tree storage rule?
To view all questions and flashcards with answers, click on the resource link above. Page 17

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) <T> is a wildcard used to specify a wide range of parameters.
A)True
B)False
Q3) The List interface is for collections that allow repetition of elements and do not impose an order on their elements.
A)True
B)False
Q4) When an interface lists a method as "optional," you do not need to implement it when defining a class that implements the interface.
A)True
B)False
Q5) What must you do before adding a primitive type to a vector?
Q6) The method ___________ can be used to determine the number of elements in an ArrayList.
A)length()
B)vectorLength()
C)size()
D)vectorSize()
To view all questions and flashcards with answers, click on the resource link above. Page 18

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) Write a Java statement to add a title to the window in the GUI created in number 1 above that says "First Window".
Q2) Composition indicates a/an _______________ relationship.
A)Is-a
B)Has-a
C)both A & B
D)none of the above
Q3) The JFrame method setVisible()takes one argument of type: A)byte
B)boolean
C)int
D)short
Q4) A ____________ is the smallest unit of space on which your screen can write. A)pixel
B)dot
C)bit
D)font
Q5) The close-window button is in the class JButton. A)True
B)False
To view all questions and flashcards with answers, click on the resource link above. Page 19

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) Write Java statements to add the icon created in number 1 above to a label that says "Love".
Q2) Explain the Java coordinate system for graphic objects.
Q3) An invocation of the Container class method _____________ updates components on the screen.
A)setVisible
B)setLayout
C)update
D)validate
Q4) The paint method of the Graphics class can only be used with Applets.
A)True
B)False
Q5) 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
Q6) Write a Java statement that uses a Graphics object to display "Hello World" at position 50,100.
Page 20
To view all questions and flashcards with answers, click on the resource link above.

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) SQL stands for Structured Query Language.
A)True
B)False
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) Java's Thread class is in the ____________ package.
A)java.util
B)java.thread
C)java.lang
D)javax.swing
Q4) ____________ refers to a framework that facilitates software building by connecting software components from diverse sources.
A)JavaBeans
B)Threads
C)SQL
D)all of the above
To view all questions and flashcards with answers, click on the resource link above. Page 21

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 a recursive method to compute the factorial of a number.
Q2) Regarding recursion,if a base case is never reached the result is:
A)infinite recursion
B)iteration
C)termination
D)all of the above
Q3) All recursive methods must have a/an:
A)starting case
B)intermediate case
C)stopping case
D)none of the above
Q4) What are the two base cases for a recursive binary search algorithm?
Q5) A recursive method must never return a value.
A)True
B)False
Q6) Explain how the binary search works.
Q7) The binary search algorithm has worst-case running time that is logarithmic.
A)True
B)False
Q8) What is a stack overflow?
To view all questions and flashcards with answers, click on the resource link above. Page 22

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) The HTML tag used to insert a horizontal line on a page is:
A)< h1 >
B)< href >
C)< hr >
D)< br >
Q3) URL stands for:
A)Unified Resource Locator
B)Uniform Reader Locator
C)Uniform Resource Locator
D)Uniform Resource Language
Q4) HTML is part of the Java language.
A)True
B)False
Q5) Write an HTML comment containing the phrase "This is a comment."
Page 23
To view all questions and flashcards with answers, click on the resource link above.