Skip to main content

Computer Science I Exam Answer Key - 1208 Verified Questions

Page 1


Computer Science I

Exam Answer Key

Course Introduction

Computer Science I is an introductory course designed to provide students with a foundational understanding of computer science principles and programming. The course covers essential topics such as algorithm development, problem-solving techniques, data types, control structures, functions, and the basics of software development. Students will learn to write, debug, and test programs using a programming language commonly used in industry, while also gaining insight into the underlying concepts that drive computational thinking. Emphasis is placed on hands-on experience and the practical application of coding skills to solve real-world problems, preparing students for more advanced courses in computer science.

Recommended Textbook

Java Programming 7th Edition by Joyce Farrell

Available Study Resources on Quizplus

17 Chapters

1208 Verified Questions

1208 Flashcards

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

Chapter 1: Creating Java Programs

Available Study Resources on Quizplus for this Chatper

68 Verified Questions

68 Flashcards

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

Sample Questions

Q1) Regarding code layout, what would be an equally valid and legal way to write the following Java code: public static void main(String[] args) { System.out.println("First Java application"); }

Answer: public static void main(String[] args) { System.out.println("First Java application"); }

Q2) You must use the Java interpreter to translate the bytecode into executable statements before running a Java application.

A)True

B)False Answer: True

Q3) Programs that are embedded in a Web page are called Java ____.

A) consoles

B) applets

C) applications

D) windowed applications

Answer: B

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

Chapter 2: Using Data

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

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

Sample Questions

Q1) You can create a confirm dialog box with five arguments.

A)True

B)False

Answer: True

Q2) A floating-point data type

A)operand

B)cast operator

C)assignment

D)operator precedence

E)garbage

F)primitive

G)float

H)boolean

I)escape sequence

Answer: G

Q3) Once a variable has been declared and initialized, new values may not be assigned to the variable.

A)True

B)False

Answer: False

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

Chapter 3: Using Methods, Classes, and Objects

Available Study Resources on Quizplus for this Chatper

68 Verified Questions

68 Flashcards

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

Sample Questions

Q1) Data components of a class

A)return statement

B)header

C)instance variables

D)methods signature

E)formal parameters

F)static method

G)data fields

H)parameter type

I)class user

Answer: C

Q2) Public classes are accessible by all objects, which means that public classes can be ____, or used as a basis for any other class.

A) saved

B) extended

C) copied

D) used

Answer: B

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

Page 5

Chapter 4: More Object Concepts

Available Study Resources on Quizplus for this Chatper

67 Verified Questions

67 Flashcards

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

Sample Questions

Q1) Variables associated with individual objects

A)optional classes

B)instance variables

C)comes into scope

D)class methods

E)overloading

F)Math class

G)redeclaring a variable

H)GregorianCalendar

I)constant

Q2) A variable comes into existence, or ____, when you declare it.

A) goes out of scope

B) comes into scope

C) overrides scope

D) is referenced

Q3) Describe the impact that blocks and methods have on variables with the same name.

Q4) Describe and provide an example of overloading.

Q5) A(n) ____________________ begins immediately after the method declaration and ends at the end of the method.

Page 6

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

Chapter 5: Making Decisions

Available Study Resources on Quizplus for this Chatper

70 Verified Questions

70 Flashcards

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

Sample Questions

Q1) You can use the ____, which is written as ||, if you want some action to occur when at least one of two conditions is true.

A) conditional OR operator

B) logical AND operator

C) range check

D) switch statement

Q2) The ____ operator is written as the exclamation point ( ! ).

A) equality

B) AND

C) assignment

D) NOT

Q3) When working with logical operators, you can always use ____ to change precedence.

A) conditional operators

B) break statements

C) parentheses

D) semicolons

Q4) Why would a programmer need to use a range check? Give an example.

Q5) ____________________ is a tool that helps programmers plan a program's logic by writing plain English statements.

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

Chapter 6: Looping

Available Study Resources on Quizplus for this Chatper

72 Verified Questions

72 Flashcards

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

Sample Questions

Q1) A loop that never ends is called a(n) ____ loop.

A) definite

B) infinite

C) while

D) for

Q2) The statements that make up a loop body will continue to execute as long as the expression value remains false.

A)True

B)False

Q3) How are indefinite loops used for validating data? Why is a loop structure typically the better choice for validating data than an if statement?

Q4) When nesting loops, the variable in the outer loop changes more frequently.

A)True

B)False

Q5) A ____ is a structure that allows repeated execution of a block of statements.

A) body

B) Boolean expression

C) loop

D) loop control

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

Chapter 7: Characters, Strings, and the Stringbuilder

Available Study Resources on Quizplus for this Chatper

73 Verified Questions

73 Flashcards

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

Sample Questions

Q1) Strings that cannot be changed are said to be immutable. What does this mean and how does it relate to values held in memory addresses?

Q2) The StringBuilder class is more efficient than the StringBuffer class because it can execute multiple threads during program execution. A)True B)False

Q3) String aName = "Michael"

Using the above statement, write the length() method that will return the length of the aName String. What value will the length() method return when executed?

Q4) String firstCompare = "Oak Maple Pine"

String secondCompare = "spruce maple elm" firstCompare.regionMatches(false, 4, secondCompare, 7, 5)

Using the above code, what will be the Boolean value after execution of the regionMatches statement? Explain how the Strings are compared using the regionMatches() method.

Q5) How is the String class equalsIgnoreCase() method like the equals() method and how would you use it? Give an example.

Q6) Describe how a reference is used in Java.

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

Chapter 8: Arrays

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

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

Sample Questions

Q1) An enhanced for loop

A)array variable

B)reference type

C)elements

D)int

E)Java object names

F)length

G)foreach loop

H)reference types

I)return

Q2) When you create an array of objects, each reference is assigned the value ____.

A) null

B) '\u0000'

C) true

D) false

Q3) When you create an array variable, memory space is automatically reserved.

A)True

B)False

Q4) Why would you use spacing when initializing parallel arrays?

Q5) What does an array's name represent and what value does it hold when declared?

Page 10

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

Chapter 9: Advanced Array Concepts

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

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

Sample Questions

Q1) Write the statement to declare an ArrayList named myVals with a capacity of 15 items. Explain the importance of capacity when working with an ArrayList.

Q2) How can you sort arrays of objects?

Q3) import java.util.*; import javax.swing.*; public class binary_search

{ public static void main(String[] args)

{ int myNums[]={2, 44, 5, 66, 78, 90, 23, 66}; int point, find = 78; point = Arrays.binarySearch(myNums, find); System.out.println("Element found at index " + point); } }

Using the above code, what output will be displayed when the program is executed? Describe how the binarySearch() method functions.

Q4) The Arrays class ____________________ method assigns the specified value to each element of the specified array.

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

Chapter 10: Introduction to Inheritance

Available Study Resources on Quizplus for this Chatper

70 Verified Questions

70 Flashcards

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

Sample Questions

Q1) Superclasses can be distinguished from their subclasses because a subclass is generally smaller than a superclass; it usually has fewer fields and methods.

A)True

B)False

Q2) Create a class named Account that contains an integer field for an account number and a double field for an account balance. The class contains a constructor that requires an account number and sets the balance to 0.0. Include a set() method for the balance, a get() method for the account number, and a get() method for the account balance. Create two subclasses named Checking and Savings. Within the Checking class, the get() method should display the String "Checking Account Information", the account number, and the balance. Within the Savings class, add a field to hold the interest rate, and require the Savings constructor to accept an argument for the value of the interest rate. The Savings get() method displays the String "Savings Account Information", the account number, the balance, and the interest.

Q3) Using a class named Student, write the statement to create a yearOne object of the Student class.

Q4) What is information hiding and how is it used?

Q5) What is the process of inlining and how is it accomplished in Java?

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

Chapter 11: Advanced Inheritance Concepts

Available Study Resources on Quizplus for this Chatper

70 Verified Questions

70 Flashcards

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

Sample Questions

Q1) If you attempt to instantiate an object from an abstract class, you receive an error message from the compiler that you have committed a(n) ____.

A) LogicError

B) InstantiationError

C) SyntaxError

D) ObjectError

Q2) When you define a class, if you do not explicitly extend another class, your class is an extension of the ____ class.

A) Object

B) super

C) public

D) abstract

Q3) Compare and contrast abstract classes and interfaces.

Q4) How is the Object class equals() method implemented?

Q5) While a class can inherit from any abstract superclass, it can only implement one interface.

A)True

B)False

Q6) What is an abstract class? Give an example and explain how it works.

Page 13

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

Chapter 12: Exception Handling

Available Study Resources on Quizplus for this Chatper

65 Verified Questions

65 Flashcards

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

Sample Questions

Q1) How is an Error class different from an Exception class?

Q2) Many developers believe that it is poor style for a method to throw more than ____ type(s) of exceptions.

A) one

B) two

C) three or four

D) eight or ten

Q3) When an exception is a checked exception, client programmers are forced to deal with the possibility that an exception will be thrown.

A)True

B)False

Q4) Unplanned exceptions that occur during a program's execution are also called execution exceptions.

A)True

B)False

Q5) What are the elements that make up a try block?

Q6) When a program contains multiple catch blocks, how are they handled?

Q7) What things might a programmer do to cause a potential exception in a program?

Q8) What advantages does object-oriented exception handling provide?

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

Chapter 13: File Input and Output

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

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

Sample Questions

Q1) When you perform input and output operations in an application, what is actually occurring with the bytes of information?

Q2) The main directory of your storage device

A)batch processing

B)root

C)buffer

D)flushing

E)stream

F)System.getProperty("line.separator")

G)data file

H)close the files

I)BufferedWriter

Q3) When a String is written, placing each record on a new line makes the output file easier to read and interpret. Since not all platforms use '\n' to separate lines, the BufferedWriter class has two alternatives: the newLine() method and the System.getProperty() method. Describe these two methods and how they operate.

Q4) Briefly describe the Path class in Java.

Q5) Describe and provide an example of the differences between real-time applications and interactive programs.

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

Chapter 14: Introduction to Swing Components

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

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

Sample Questions

Q1) When creating a Font object, the typeface name must be enclosed in double quotation marks because it is a String.

A)True

B)False

Q2) Write the statement to create a layout manager named myLayout that centers components in each row.

Q3) The ____ responds to keyboard focus events.

A) KeyListener

B) ActionListener

C) ChangeListener

D) FocusListener

Q4) What are some of the decisions you must make when extending a JFrame?

Q5) You define the text to be displayed in a tool tip by using the setToolTipText() method and passing an appropriate ____ to it.

A) Integer

B) Date

C) String

D) Boolean

Q6) How have user interface components changed since the early versions of Java?

Page 16

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

Chapter 15: Advanced Gui Topics

Available Study Resources on Quizplus for this Chatper

69 Verified Questions

69 Flashcards

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

Sample Questions

Q1) With ____, a redrawn JPanel is displayed only when it is complete; this provides the viewer with updated screens that do not flicker while being redrawn.

A) single buffering

B) double buffering

C) auto filtering

D) double framing

Q2) The parent class for all event objects is named ____, which descends from the Object class.

A) EventObject

B) Event

C) ParentEvent

D) AWTEvent

Q3) The JMenus are added to the JMenuBar using the ____ method.

A) addMenu()

B) add()

C) addNewMenu()

D) setMenu()

Q4) Describe the two CardLayout constructors.

Q5) How do you find the red, green, and blue components of a color?

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

Chapter 16: Graphics

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

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

Sample Questions

Q1) Write the statement to create a Rectangle2D.Float object named myRect at 20, 20 with a width of 80 and height of 50.

Q2) If you call getGraphics() in a frame that is not visible, you receive a(n) ____.

A) ForceQuit

B) ExecuteException

C) NonExecute

D) NullPointerException

Q3) The ____ method requires four arguments and draws the outline of a rectangle using the current drawing color.

A) clearRect()

B) drawRect()

C) fillRect()

D) paintRect()

Q4) BasicStroke myLine = new BasicStroke(12.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_ROUND);

The above statement creates a BasicStroke object and makes it the current stroke.

Describe the three arguments that are used in this statement, and then describe the purpose of each.

Q5) What activities does the process of drawing with Java 2D objects include?

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

Chapter 17: Applets, Images, and Sound

Available Study Resources on Quizplus for this Chatper

72 Verified Questions

72 Flashcards

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

Sample Questions

Q1) Retrieves and plays the sound as soon as possible after it is called

A)current version of HTML

B)init()

C)start()

D)HTML

E)Applet Viewer

F)tags

G)multimedia

H)applet

I)play()

Q2) What are the two forms of the play() method?

Q3) The ____ command is part of the Java Development Kit (JDK), which provides a convenient environment in which to test your applets.

A) appletview

B) appletviewer

C) viewapplet

D) av

Q4) To run an applet from an HTML document, you add an <object> and ___________________ tag pair.

Q5) A(n) ___________________ is a likeness of a person or thing.

Page 19

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

Turn static files into dynamic content formats.

Create a flipbook