Skip to main content

Introduction to Computer Science Exam Review - 639 Verified Questions

Page 1


Introduction to Computer Science Exam Review

Course Introduction

Introduction to Computer Science provides a comprehensive overview of the fundamental concepts in computing and programming. The course covers topics such as problem-solving techniques, algorithms, data structures, computer organization, networks, and the basics of computer hardware and software. Students will learn the foundational principles of programming through hands-on exercises in a high-level language, developing skills to write, test, and debug simple programs. Emphasis is also placed on the impact of computing on society, ethical concerns, and opportunities within the field. This course serves as a gateway for further study in computer science and related disciplines.

Recommended Textbook

Java Foundations 3rd Edition by John Lewis

Available Study Resources on Quizplus

16 Chapters

639 Verified Questions

639 Flashcards

Source URL: https://quizplus.com/study-set/3997 Page 2

Chapter 1: Introduction

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/80262

Sample Questions

Q1) In order for a program to run on a computer, it must be expressed in ______________________.

A) an assembly language

B) a machine language

C) a high-level language

D) an object-oriented language

E) a fourth generation language

Answer: B

Q2) Write a program that outputs Four Score and Seven Years Ago on six lines, with the words centered relative to each other.

Answer: 11edd9cc_ee20_b559_84e8_3972ed1653d9_TB2841_00

Q3) An interpreter is a program that translates code that is written in one language into equivalent code in another language.

A)True

B)False

Answer: False

Q4) Write an application that prints the first few lines of a song (your choice).

Answer: 11edd9cc_5a45_7376_84e8_afca069acf96_TB2841_00

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

Page 3

Chapter 2: Data and Expressions

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/80257

Sample Questions

Q1) Which of the following is an example of an invalid expression in Java?

A) result = a + b;

B) result = (14 + 9) * 5;

C) result = ((19 + 4) - 5;

D) result = firstNum % secondNum;

E) result = firstNum / secondNum % thirdNum;

Answer: C

Q2) Which of the following are examples of invalid string literals?

A) "Hello World!"

B) "4 score and 7 years ago, our forefathers brought forth..."

C) "z"

D) ""

E) none of the above

Answer: E

Q3) Java is a strongly-typed language.

A)True

B)False

Answer: True

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

4

Chapter 3: Using Classes and Objects

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/80255

Sample Questions

Q1) A variable that is declared as a primitive type stores the actual value of the associated data. A variable that is declared as an object type stores a pointer to the associated object.

A)True

B)False

Answer: True

Q2) Which of the following best describes what happens when an object no longer has any references pointing to it?

A) The object is overwritten the next time the new operator is called.

B) The object is overwritten the next time the new operator is called using the same class.

C) The object is immediately deleted from memory.

D) The object is marked as garbage and its associated memory is freed when the garbage collector runs.

E) The object stays in memory for the remainder of the programs execution.

Answer: D

Q3) Write an expression that computes 12 raised to the power 4.3 and store the result in a double called result.

Answer: result = Math.pow(12, 4.3);

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

Page 5

Chapter 4: Conditionals and Loops

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/80254

Sample Questions

Q1) The ___________________ statement causes current iteration of a loop to stop and the condition to be evaluated again, either stopping the loop or causing the next iteration.

A) stop

B) halt

C) continue

D) break

E) switch

Q2) Write a for loop to print the even numbers from 1 to 100 (inclusive).

Q3) What is wrong with the following snippet of code? Rewrite it so it produces the correct output.

if(a < b)

if(a == c)

System.out.println( a < b and a == c );

else

System.out.println( a is not less than b );

Q4) Using a while loop, write a code fragment that computes the sum of the first n natural numbers (i.e. 1, 2, 3, 4, ... n), where n is an integer variable already defined in the program.

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

Chapter 5: Writing Classes

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/80253

Sample Questions

Q1) Write a method called isPalindrome that accepts a String as a parameter and returns true if the String is a palindrome, and false otherwise. You may assume that the entered String consists entirely of lowercase letters (meaning it contains no numbers, spaces, punctuation, etc). Hint: write code that creates a new string that is the original string reversed, and then check to see if the two strings are equal.

Q2) When an object is passed to a method, the actual and formal parameters become aliases.

A)True B)False

Q3) The versions of an overloaded method are distinguished by ___________________________.

A) the number, type and order of their parameters

B) their identifiers

C) their classes

D) the number and type of their parameters

E) the number of their parameters

Q4) A programmer is required to define a constructor for every class.

A)True B)False

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

Chapter 6: Graphical User Interfaces

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/80252

Sample Questions

Q1) Check boxes operate as a group, providing a set of mutually exclusive options.

A)True

B)False

Q2) Which of the following represents a dialog box that allows the user to select a file from a disk or other storage medium?

A) color chooser

B) disk chooser

C) tool tip chooser

D) file chooser

E) none of the above

Q3) A mnemonic is a short line of text that will appear when the cursor is rested momentarily on top of the component.

A)True

B)False

Q4) GUI is an acronym for _______________________.

A) graphical UML interface

B) graphical UML implementation

C) graphical user implementation

D) graphical user interface

E) none of the above

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

Chapter 7: Arrays

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/80251

Sample Questions

Q1) Write a method that takes in at least one integer and returns the largest of all integer parameters sent in.

Q2) Write a method called containsPair that accepts an array of integers as a parameter and returns true if it contains two integers that are equal.

Q3) Which of the following array declarations are invalid?

A) int[] grades = new int[5];

B) int grades[] = new int[5];

C) int[] grades = { 91, 83, 42, 100, 77 };

D) all of the above are valid

E) none of the above are valid

Q4) Which of the statements is true about the following code snippet? int[] array = new int[25]; Array[25] = 2;

A) The integer value 2 will be assigned to the last index in the array.

B) The integer value 25 will be assigned to the second index in the array.

C) The integer value 25 will be assigned to the third value in the array.

D) This code will result in a compile-time error.

E) This code will result in a run-time error.

Q5) Explain how arrays are passed to methods as parameters.

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

Chapter 8: Inheritance

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/80250

Sample Questions

Q1) The special reference _________________ is used to refer to the parent class in a child class.

A) this

B) super

C) null

D) parent

E) none of the above

Q2) When a variable is declared in a subclass has the same name as a variable declared in a superclass, it is called a _______________ variable.

A) final

B) shadow

C) static

D) dead

E) this is not allowed in Java

Q3) Explain what it means for a child class to override a parent class. Why might this be useful?

Q4) Draw a hierarchy of people at a University.

Q5) What does it mean for a class to be declared as final? What does it mean for a method to be declared as final?

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

Chapter 9: Polymorphism

Available Study Resources on Quizplus for this Chatper

39 Verified Questions

39 Flashcards

Source URL: https://quizplus.com/quiz/80249

Sample Questions

Q1) Why can't an interface be instantiated?

Q2) The commitment to execute certain code to carry out a method invocation is referred to as _________________.

A) execution

B) binding

C) polymorphism

D) inheritance

E) none of the above

Q3) If a class implements an interface, it cannot extend another class.

A)True

B)False

Q4) In Java, a(n) ___________________ is a collection of constants and abstract methods.

A) polymorphic reference

B) abstract class

C) implementation

D) interface

E) iterator

Q5) Describe the Iterator interface.

Q6) How do interfaces relate to multiple inheritance?

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

Chapter 11: Recursion

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/80260

Sample Questions

Q1) In a recursive solution, _______________ is(are) always necessary.

A) short, efficient code

B) several variables

C) numerous lines of code

D) a base case

E) none of the above

Q2) Describe a recursive solution to the Towers of Hanoi puzzle with N disks.

Q3) The Towers of Hanoi puzzle cannot be solved iteratively.

A)True

B)False

Q4) Write the recursive definition of the factorial of a number.

Q5) Recursion is necessary.

A)True

B)False

Q6) What is recursion?

Q7) Describe a recursive solution to determine whether a String object is a palindrome. You may assume that the string only contains lower case characters (i.e. no numbers, spaces, punctuation, etc). Hint: It may be easiest to describe your solution using pseudocode.

Q8) What are the "base" cases when searching for a path through a maze?

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

Chapter 10: Exceptions

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/80261

Sample Questions

Q1) The getMessage method of the Exception class prints out the stack trace, which helps the user to track down the source of the exception.

A)True

B)False

Q2) Which of the following represents the standard input stream?

A) System.in

B) System.out

C) System.err

D) System.instream

E) System.outstream

Q3) What is a catch clause?

Q4) Unchecked exceptions must be caught or propogated, or a program will not compile.

A)True

B)False

Q5) Write a code fragment that will throw an ArithmeticException. Your code fragment should not use the throw statement.

Q6) Is the Exception class a subclass of the Error class? Explain.

Q7) What are the standard I/O streams?

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

Chapter 12: Searching and Sorting

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/80259

Sample Questions

Q1) Which of the following algorithms has a time complexity of O(log<sub>2</sub> n)?

A) insertion sort

B) selection sort

C) bubble sort

D) linear search

E) binary search

Q2) Bubble sort is the most efficient searching algorithm.

A)True

B)False

Q3) Explain how quick sort works.

Q4) A linear search always requires more comparisons than a binary search.

A)True

B)False

Q5) A _______________ search is more efficient than a linear search.

A) binary

B) selection

C) insertion

D) bubble

E) none of the above

Q6) Explain how merge sort works.

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

Chapter 13: Trees

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/80258

Sample Questions

Q1) Suppose we are implementing a binary tree as a linked structure of BinaryTreeNode objects. Write a method that will print out all of the nodes of tree via a preorder traversal. You may assume that the class has a reference to a BinaryTreeNode object called root. In addition, your method may take a reference to a BinaryTreeNode object as a parameter.

Q2) A _________________ can be used as the basis for an expert system.

A) queue

B) stack

C) ternary tree

D) 4-ary tree

E) decision tree

Q3) Explain the implementation of a level-order traversal of a tree.

Q4) In an inorder traversal, the root is the first element to be visited in the tree.

A)True

B)False

Q5) What is the root of a tree?

Q6) A binary tree is a tree in which any node can have at most two children.

A)True

B)False

Page 15

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

Chapter 14: Introduction to Collections and Stacks

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/80248

Sample Questions

Q1) A queue is a ____________________ data structure.

A) LIFO

B) FIFO

C) link based

D) array based

E) none of the above

Q2) Suppose there were no count variable stored for the linked implementation of a queue. Would it still be possible to implement a constant time size operation? How about if there were no count variable stored for an array based implementation of a queue?

Q3) A stack is a ___________________ data structure.

A) LIFO

B) FIFO

C) link based

D) array based

E) none of the above

Q4) List the five basic operations on a stack.

Q5) It is only possible to implement a queue using an array-based structure.

A)True

B)False

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

Chapter 15: Heaps and Priority Queues

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/80247

Sample Questions

Q1) Left and right rotations can be used to rebalance an unbalanced binary search tree.

A)True

B)False

Q2) Explain how heap sort works.

Q3) Which of the following is always true when adding an element to a heap?

A) The new element will always be a leaf.

B) The new element will always be the root.

C) The new element will always be an internal node.

D) The new element will always have 2 children.

E) none of the above is always true

Q4) In a binary search tree, the elements in the right subtree of the root are always larger than the element stored at the root.

A)True

B)False

Q5) Describe the steps involved in performing a right rotation on a node in a binary search tree.

Q6) What is the inorder successor of a node in a binary search tree?

Q7) What is a heap?

Q8) Explain the process of removing an element from a binary search tree.

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

Chapter 16: Graphs

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

Source URL: https://quizplus.com/quiz/80256

Sample Questions

Q1) Consider the following undirected graph. vertices: 1, 2, 3, 4, 5 edges: (1,2),(3,4), (2,4), (2, 3), (3,5), (4,5)

Give a spanning tree for this graph.

Q2) A complete graph on n vertices has n(n-1)/2 edges.

A)True

B)False

Q3) A(n) _______________________ is one implementation of a graph where the graph is implemented as a linked structure, and each node contains a structure that contains links to all other nodes.

A) adjacency list

B) adjacency matrix

C) digraph list

D) graph node

E) none of the above

Q4) Write out all of the edges in a complete graph on 4 vertices.

Q5) A digraph and an directed graph are the same thing.

A)True

B)False

Q6) What data structure is used to support a depth-first traversal of a graph?

Page 18

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

Turn static files into dynamic content formats.

Create a flipbook
Introduction to Computer Science Exam Review - 639 Verified Questions by Quizplus - Issuu