Computer Science I Exam Solutions - 620 Verified Questions

Page 1


Computer Science I Exam Solutions

Course Introduction

Computer Science I provides an introduction to fundamental concepts in computer science, focusing on problem solving, algorithm development, and programming using a high-level language. Topics covered include variables, control structures, functions, arrays, and basic data structures, along with the principles of software design, debugging, and testing. Through hands-on assignments and projects, students develop computational thinking and foundational programming skills essential for further study in computer science.

Recommended Textbook

Starting Out with Java Early Objects 5th Edition by Tony Gaddis

Available Study Resources on Quizplus

16 Chapters

620 Verified Questions

620 Flashcards

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

Chapter 1: Introduction to Computers and Java

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

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) Because Java byte code is the same on all computers, compiled Java programs

A) are non-existent.

B) must be re-compiled for each different machine it is run on.

C) are highly portable.

D) cannot run on computers with different operating systems.

Answer: C

Q3) Computers can do many different jobs because they are A) programmable.

B) reliable.

C) automated.

D) electronic.

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

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Which of the following is not a valid Java comment?

A) /** Comment 1 */

B) */ Comment 2 /*

C) // Comment 3

D) /* Comment 4 */

Answer: B

Q2) What will be the value of z after the following statements have been executed?

int x = 4, y = 33;

Double z;

Z = (double) (y / x);

A) 8.25

B) 4

C) 0

D) 8.0

Answer: D

Q3) A message dialog is a quick and simple way to ask the user to enter data.

A)True

B)False

Answer: False

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

Page 4

Chapter 3: A First Look at Classes and Objects

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Shadowing is the term used to describe where the field name is hidden by the name of a local or parameter variable.

A)True

B)False

Answer: True

Q2) Another term for an object of a class is a(n)

A) access specifier.

B) instance.

C) member.

D) method.

Answer: B

Q3) A method that gets a value from a class's field but does not change it is known as a mutator method.

A)True

B)False

Answer: False

Q4) An access specifier indicates how the class may be accessed.

A)True

B)False

Answer: True

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

Chapter 4: Decision Structures

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) If the expression on the left side of the && operator is false, the expression on the right side will not be checked.

A)True

B)False

Q2) Which of the following strings could be passed to the DecimalFormat constructor to display 12.78 as 012.8?

A) "###.#"

B) "000.0"

C) "##0.0%"

D) "$#0.00"

Q3) Unicode is an international encoding system that is extensive enough to represent all the characters of all the world's alphabets.

A)True

B)False

Q4) A local variable's scope always ends at the closing brace of the block of code in which it is declared.

A)True

B)False

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

Chapter 5: Loops and Files

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) How many times will the following for loop be executed? For (int count = 10; count <= 21; count++) System.out.println("Java is great!");

A) 0

B) 12

C) 10

D) 11

Q2) A for loop normally performs which of these steps?

A) update the control variable during each iteration

B) test the control variable by comparing it to a maximum/minimum value and terminate when the variable reaches that value

C) initialize a control variable to a starting value

D) All of the above

Q3) A loop that repeats a specific number of times is known as a(n) ________ loop. A) count-controlled

B) infinite

C) conditional

D) pretest

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

7

Chapter 6: 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/20984

Sample Questions

Q1) If you have defined a class SavingsAccount with a public static method getNumberOfAccounts, and created a SavingsAccount object referenced by the variable account20, which of the following will call the getNumberOfAccounts method?

A) account20.getNumberOfAccounts();

B) SavingsAccount.getNumberOfAccounts();

C) getNumberOfAccounts();

D) None of the above

Q2) A static field is created by placing the key word static

A) after the access specifier and field's data type.

B) after the access specifier and before the field's data type.

C) after the field name.

D) in brackets, before the field's data type.

Q3) By default, a reference variable that is an instance field is initialized to the value A) null.

B) 0.

C) void.

D) static.

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

Chapter 7: Arrays and the ArrayList Class

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) You use this method to determine the number of items stored in an ArrayList object. A) items

B) listLength

C) size

D) volume

Q2) This method returns a string representing all of the items stored in an ArrayList object.

A) show

B) toString

C) print

D) getList

Q3) What does &lt;String&gt; specify in the following statement? ArrayList&lt;String&gt; nameList = new ArrayList&lt;String&gt;();

A) It specifies that String objects may not be stored in the ArrayList object.

B) It specifies that everything stored in the ArrayList object will be converted to a String object.

C) It specifies that only String objects may be stored in the ArrayList object.

D) It specifies that the ArrayList will be converted into a String array.

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

9

Chapter 8: Text Processing and Wrapper Classes

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Which of the following import statements is required to use the StringTokenizer class?

A) import java.util.Scanner

B) import java.text.DecimalFormat;

C) import java.util.StringTokenizer;

D) import javax.swing.JOptionPane;

Q2) In the ________ file format, when the data in a spreadsheet is exported, each row is written to a line, and the values in the cells are separated by commas.

A) comma separated value

B) extensible markup language

C) excel binary

D) data interchange

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

Q4) Most of the String comparison methods are case sensitive.

A)True

B)False

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

10

Chapter 9: Inheritance

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) You can use this operator to determine whether an object is an instance of a particular class.

A) equals

B) instanceof

C) >>

D) isa

Q2) When a subclass overrides a superclass method, only the subclass's version of the method can be called with a subclass object.

A)True

B)False

Q3) In the following statement, which is the superclass?

Public class ClassA extends ClassB implements ClassC

A) ClassA

B) ClassB

C) ClassC

D) ClassB and ClassC

Q4) An abstract class is not instantiated itself, but serves as a superclass for other classes.

A)True

B)False

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

Chapter 10: Exceptions and Advanced File I/O

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) A file that contains raw binary data is known as a(n)

A) binary file.

B) machine file.

C) serial file.

D) raw data file.

Q2) When writing a string to a binary file or reading a string from a binary file, it is recommended that you use

A) methods that use UTF-8 encoding.

B) the FileReader and Writer class methods.

C) the Scanner class methods.

D) the System.In and System.Out methods.

Q3) When using the throw statement, if you do not pass a message to the exception object's constructor,

A) the exception will have a null message.

B) the exception will have a message containing the address of the exception.

C) the exception will a default message describing the exception.

D) a compiler error will occur.

Q4) The throws clause causes an exception to be thrown.

A)True

B)False

Page 12

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

Chapter 11: GUI Applications Part 1

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) In GUI terminology, a container that can be displayed as a window is known as a A) buffer.

B) message dialog.

C) Swing package.

D) frame.

Q2) Event listeners must

A) exit the application once it has handled the event.

B) not receive any arguments.

C) be included in private inner classes.

D) implement an interface.

Q3) This method of the JOptionPane class is used to display a confirm dialog box.

A) showConfirmDialog

B) showConfirmationDialog

C) showConDialog

D) showCDialog

Q4) A modal dialog box

A) suspends execution of any other statements until the dialog box is closed.

B) is displayed for a short period of time and then disappears from the screen.

C) always appears in the center of the screen.

D) determines the mode your program runs in.

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

Chapter 12: GUI Applications Part 2

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) The Dimension class is part of the ________ package.

A) java.awt.menu

B) javax.swing.event

C) javax.swing

D) java.awt

Q2) What is the default directory for the JFileChooser constructor when you pass a String containing a valid path as an argument?

A) If you are using Windows, this will probably be the "My Documents" folder under your account.

B) If you are using UNIX, this will be your login directory.

C) Both A and B

D) None of the above

Q3) To force the JFrame that encloses a window to resize itself automatically when a larger object is placed in the frame, use the ________ method.

A) resize

B) refresh

C) pack

D) extend

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

14

Chapter 13: Applets and More

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) Which of the following is one way to get a reference to the Graphics object for an AWT component or a class that extends JApplet or JFrame?

A) Override the component's paint method.

B) Create a static instance of the Graphics object.

C) Pass an instance of the Graphics object as an argument to the component's constructor.

D) Create an instance of any class that extends the Graphics2D class.

Q2) Applets are important because they can be used to extend the capabilities of a stand-alone Java application.

A)True

B)False

Q3) An application can use this object to execute code automatically at regular time intervals.

A) Clock

B) Regulator

C) Meter

D) Timer

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

15

Chapter 14: Creating GUI Applications with JavaFX

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) This is a name that identifies a component in the FXML file and will also become a variable name that you can use later in the Java code that you will write to run the application.

A) fx:id

B) fx_id

C) FXID

D) fx.URL

Q2) Although these are often displayed in groups, they are not usually grouped in a toggle group like RadioButtons are.

A) Labels

B) CheckBoxes

C) Buttons

D) TextFields

Q3) The ________ is responsible for handling events that occur while the JavaFX application is running.

A) abstract class

B) main application class

C) controller class

D) super class

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

20 Verified Questions

20 Flashcards

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

Sample Questions

Q1) The recursive case does not require recursion, so it stops the chain of recursive calls.

A)True

B)False

Q2) A recursive method can have no more than one base case.

A)True

B)False

Q3) Whereas a recursive algorithm might result in faster execution time, the programmer might be able to design an iterative algorithm faster.

A)True

B)False

Q4) The recursive binary search algorithm is a good example of repeatedly breaking a problem down into smaller pieces until it is solved.

A)True

B)False

Q5) Recursion is never absolutely required to solve a problem.

A)True

B)False

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

Page 17

Chapter 16: Databases

Available Study Resources on Quizplus for this Chatper

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) In SQL, the equal to operator is ==, which is the same as Java.

A)True

B)False

Q2) SQL stands for

A) structured query language.

B) standard equivalent language.

C) semiconductor qualified language.

D) simple equation library.

Q3) Of the following column names, which one is most likely a primary key column?

A) Price

B) Description

C) ItemNumber

D) Quantity

Q4) Which of the following is a Swing component that displays data in a two-dimensional table?

A) JTable

B) JFrame

C) JPanel

D) JTable2D

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

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.