Skip to main content

Computer Science I Textbook Exam Questions - 981 Verified Questions

Page 1


Computer Science I

Textbook Exam Questions

Course Introduction

Computer Science I is an introductory course designed to provide students with a foundational understanding of computer science concepts and programming principles. The course covers topics such as algorithms, data types, control structures, problem-solving techniques, and software development. Through hands-on programming assignments often using languages like Python or Java students will learn how to design, implement, test, and debug basic programs. This course emphasizes logical thinking, computational problem solving, and the development of efficient, readable, and maintainable code, preparing students for more advanced study in the field.

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) A runtime error is usually the result of:

A) A logical error

B) A syntax error

C) A compilation error

D) Bad data

Answer: A

Q2) Byte code instructions are:

A) Another name for source code

B) Syntax errors

C) Machine code instructions

D) Read and interpreted by the JVM

Answer: D

Q3) When an object's internal data is hidden from outside code and access to that data is restricted to the object's methods,the data is protected from accidental corruption.

A)True

B)False

Answer: True

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) Variables are classified according to their

A) value

B) data type

C) names

D) location in the program

Answer: B

Q2) In Java the variable named one is the same as the variable named One.

A)True

B)False

Answer: False

Q3) A Java program must have at least one of these:

A) Class definition

B) Variable

C) Comment

D) System.out.println();statement

Answer: A

Q4) All Java statements end with semicolons.

A)True

B)False

Answer: False

Page 4

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

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) Which of the following correctly tests the char variable chr to determine whether it is not equal to the character B?

A) if (chr > 'B')

B) if (chr < 'B')

C) if (chr != 'B')

D) if (chr != "B")

Answer: C

Q2) When testing for character values,the switch statement does not test for the case of the character.

A)True

B)False

Answer: False

Q3) If chr is a character variable,which of the following if statements is written correctly?

A) if (chr = "a")

B) if (chr == "a")

C) if (chr = 'a')

D) if (chr == 'a')

Answer: D

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

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) Which of the following are pre-test loops?

A) while,for,do-while

B) while,do-while

C) while,for

D) for,do-while

Q2) The do-while loop must be terminated with a semicolon.

A)True

B)False

Q3) A loop that executes as long as a particular condition exists is called a(n)

A) sentinel loop

B) conditional loop

C) count-controlled loop

D) infinite loop

Q4) When you pass the name of a fi le to the PrintWriter constructor,and the file already exists,it will be erased and a new empty file with the same name will be created.

A)True

B)False

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

6

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) What will be returned from the following method? public static int methodA()

{ Double a = 8.5 + 9.5; Return a;

} A) 18.0

B) 18 (as an integer)

C) 8.0

D) This is an error

Q2) What will be returned from the following method? public static double methodA()

{

Double a = 8.5 + 9.5;

Return a; }

A) 18.0

B) 18 (as an integer)

C) 8

D) This is an error

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) Two or more methods in a class may have the same name as long as

A) they have different return types

B) they have different parameter lists

C) they have different return types,but the same parameter list

D) you cannot have two methods with the same name

Q2) 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

Q3) The scope of a public instance field is

A) only the class in which it is defined

B) inside the class,but not inside any method

C) inside the parentheses of a method header

D) the instance methods and methods outside the class

Q4) Instance methods should be declared static.

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) Which of the following statements is not true?

A) Radio buttons are round and check boxes are square.

B) Radio buttons are often grouped together and are mutually exclusive;Check boxes are not

C) Radio buttons and check boxes both implement the ActionListener interface

D) They are all true

Q2) If button1 is a JButton object,which of the following statements will make its background blue?

A) button1.makeBackground(BLUE);

B) button1.setBackground(Color.BLUE);

C) button1.makeBackground(Color.BLUE);

D) button1.set.Background(BLUE);

Q3) When this is the argument passed to the JFrame class's setDefaultCloseOperation()method,the application is hidden,but not closed.

A) HIDE_ON_CLOSE

B) JFrame.HIDE_ON_CLOSE

C) JFrame.EXIT_ON_CLOSE

D) JFrame.HIDE_NOT_CLOSE

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

9

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) You can use this ArrayList class method to replace an item at a specific location in an ArrayList.

A) replace

B) add

C) store

D) set

Q2) Which of the following is a correct method header for receiving a two-dimensional array as an argument?

A) public static void passArray(int[1,2])

B) public static void passArray(int [][])

C) public static void passArray(int[1],[2])

D) public static void passArray(int[],int[])

Q3) The String[] args parameter in the main method header allows the program to receive arguments from the operating system command-line.

A)True

B)False

Q4) Java limits the number of dimensions that an array may have to 15.

A)True

B)False

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

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) If the this variable is used to call a constructor,

A) a compiler error will result,if it is not the first statement of the constructor.

B) a compiler error will result,if it is the first statement of the constructor.

C) nothing will happen.

D) The this variable cannot be used as a constructor call.

Q2) When the this variable is used to call a constructor,

A) it must be the first statement in the constructor making the call

B) it must be the last statement in the constructor making the call

C) it can be anywhere in the constructor making the call

D) You cannot use the this variable in a constructor call.

Q3) A deep copy of an object

A) is an assignment of that object to another object

B) is an operation that copies an aggregate object,and all the objects it references

C) is a bogus term,it has no meaning

D) is always a private method

Q4) An enumerated data type is actually a special type of class.

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) For the following code,how many times would the while loop execute? StringTokenizer strToken = New StringTokenizer("Ben and Jerry's ice cream is great."); While (strToken.hasMoreTokens()) { System.out.println(strToken.nextToken());

}

A) 1

B) 3

C) 5

D) 7

Q2) What will be the value of matches after the following code is executed? boolean matches; String[] productCodes = {"456HI345","3456hj"}; Matches = productCodes[0].regionMatches(true,1, ProductCodes[1],2,3);

A) 56H B) 56h

C) true

D) 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) In the following statement,which is the interface? public class ClassA extends ClassB implements ClassC

A) ClassA

B) ClassB

C) ClassC

D) Cannot tell

Q2) Look at the following code and determine what the call to super will do. public class ClassB extends ClassA { Public ClassB() { Super(10); } }

A) This cannot be determined form the code shown.

B) It will call the constructor of ClassA that receives an integer as an argument.

C) It will call the method named super and pass the value 10 to it as an argument.

D) The method super will have to be defined before we can say what will happen.

To view all questions and flashcards with answers, click on the resource link above. Page 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) Classes that inherit from the Error class are

A) for exceptions that are thrown when a critical error occurs,and the application program should not try to handle them.

B) for exceptions that are thrown when a critical error occurs,and the application program should try to handle them.

C) for exceptions that are thrown when an IOException occurs,and the application program should not try to handle them.

D) for exceptions that are thrown when an IOException error occurs,and the application program should try to handle them.

Q2) If a random access file contains a stream of characters,which of the following would you use to set the pointer on the fifth character?

A) file.seek(4);

B) file.seek(5); C) file.seek(9);

D) file.seek(8);

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.

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) Which of the following statements creates a horizontal slider component with a minimum value of 0,a maximum value of 50,and an initial value of 25?

A) JSlider slider = New JSlider(0,50,25,JSlider.HORIZONTAL);

B) JSlider slider = New JSlider(JSlider.HORIZONTAL,0,50,25);

C) JSlider slider = New JSlider(JSlider.HORIZONTAL,25,0,50);

D) JSlider slider = New JSlider(JSlider.HORIZONTAL,50,0,25);

Q2) When you create an instance of the JList class,

A) you pass an array of objects to the constructor.

B) the list has a default selection mode of Single Selection Mode.

C) the values in the list are automatically sorted.

D) you must indicate the maximum number of list items the user may select at any one time.

Q3) 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.

Page 15

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 delay parameter in the Timer constructor is the amount of time between action events,measured in milliseconds.

A)True

B)False

Q2) In the link produced by the following HTML,what word would you click to go to the linked location? Click here to learn more about < a href="http://www.applications.com" >applications.< /a >

A) Click

B) here

C) Click here to learn more about D) applications

Q3) Given the following code,how many times per second will the TimerListener event be generated? Timer timer = new Timer(1000,new TimerListener());

A) 1

B) 10

C) 100

D) 1000

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) How many times will the following method call itself,if 10 is passed as the argument? public static void message(int n)

{ If (n < 0)

{ System.out.println("Print this line. \ n");

Message(n + 1);

A) 0

B) 9

C) 10

D) An infinite number of times

Q2) Which of the following problems cannot be programmed recursively?

A) Towers of Hanoi

B) Summing a range of array elements

C) Finding the greatest common divisor

D) All of the above can be programmed recursively

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) If a[ ] is an array of integers,the pseudo code

Int k = 0

Int m = 1

While m < a.length If a[m] < a[k] Then K = m

End If M = m+1

End While

Describes a strategy for

A) sorting an array in ascending order

B) sorting an array in descending order

C) implementing a part of the logic for bubble sort

D) determining the location of the smallest value in the array

Q2) 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. Page 18

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) When a generic method is called,

A) the programmer must explicitly specify the actual types to use for the type parameters

B) the compiler determines the actual types to use for the type parameters from the context

C) the compiler uses information explicitly specified by the programmer,if available;otherwise,the type defaults to Object

D) None of the above

Q2) Let Point< T > be a generic type.We want to write a method that takes as parameter Point objects whose type parameter is the Number class,or any subclass of Number.We can do this by declaring the type of the method parameter as

A) Point< Number >

B) Point< ? super Number >

C) Point< ? extends Number >

D) Point< ? sub Number >

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) LinkedHashSet differs from HashSet because

A) the LinkedHashSet stores objects that have the same hash code in the same bucket

B) the LinkedHashSet is a subclass of TreeSet

C) the LinkedHashSet allows elements to be retrieved in the same order as they were added

D) the LinkedHashSet is a subclass of LinkedList

Q2) 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

Q3) When the next( )method of Iterator is called at the end of a collection,it

A) throws NoSuchElementException

B) returns null

C) wraps around to the beginning of the collection and returns the first element

D) returns the a copy of the last element returned

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

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) A constructor for an array-based list takes an integer parameter,to be used as the capacity of the internal array of the list.Which exception should the constructor throw if its parameter is zero or negative?

A) IllegalArgumentException

B) IllegalStateException

C) RuntimeException

D) NullPointerException

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 void clear()that removes all elements from the list.

Q3) The position of an item within a list is called its A) index

B) rank C) level

D) number

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

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) A doubly linked list makes it easy to

A) move from any node to its successor,and from any node to its predecessor

B) skip two nodes at a time when moving forward through the list

C) skip two nodes at a time when moving backward through the list

D) to create a second copy of the linked list

Q2) 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

Q3) A linked list class keeps its elements in the order in which they are added,with the index of an element X being greater than the index of any element added to the list before X.Addition of new elements to such a list can be made more efficient

A) by keeping a reference to the element with the least index

B) by starting at the head,and quickly traversing the list to locate the place where a new element should be added

C) by keeping a reference to the last element added

D) None of the above

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

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 queue 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) in a first-in-last-out fashion

D) quickly and efficiently

Q2) A queue invariant is a condition

A) obeyed by queues that need to remain constant

B) that is required to be true after the execution of each queue class method

C) that is more stringent than invariants for other types of collections

D) that is true regardless of the actual type used to instantiate a generic queue.

Q3) The stack pop operation

A) removes all items currently on the stack

B) extracts one element from the stack and returns it

C) removes from the stack the number of elements specified by its integer parameter D) does not exist: There is no such stack operation

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

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) To find the minimum node in a binary search tree

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

Q2) The depth of a binary tree

A) is the length of the longest path from the root to a leaf

B) is the length of the shortest path from the root to a leaf

C) is the total number of leaves in the tree

D) is the depth of one of the subtrees plus one

Q3) A binary tree traversal method that recursively traverses the left subtree,then visits the root,then traverses the right subtree is called

A) root-centric traversal

B) priority order traversal

C) postorder traversal

D) inorder traversal

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

Turn static files into dynamic content formats.

Create a flipbook