Computer Science I Test Preparation - 1208 Verified Questions

Page 1


Computer Science I Test Preparation

Course Introduction

Computer Science I is an introductory course that explores the fundamental principles of computer science and programming. Students will learn the basics of problem-solving, algorithm development, and data representation, with a strong focus on designing and implementing solutions using a modern programming language. Key topics include control structures, variables, functions, arrays, and basic object-oriented concepts. By combining theoretical concepts with practical programming exercises, the course lays the groundwork for advanced studies in computer science and equips students with essential computational thinking skills.

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) Any combination of nonprinting characters

A)literal string

B)high-level programming languages

C)dialog box

D)syntax

E)whitespace

F)compiler

G)attributes

H)Machine language

I)Java virtual machine (JVM)

Answer: E

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) Describe the variation types byte, short, and long of the integer type.

Answer: The types byte, short, and long are all variations of the integer type. The byte and short types occupy less memory and can hold only smaller values; the long type occupies more memory and can hold larger values.

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) A(n) ____________________ number contains decimal positions.

Answer: floating-point float double

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) Methods use memory locations to hold values of variables. Describe the process of memory allocation and variable scope.

Answer: Each time a method executes, memory locations are assigned. They hold copies of the values that were passed to it by the main() method. When the method reaches the closing curly brace, the method ends and the variable ceases to exist. The memory location that held the value is released at the end of the method, and changes made to its value do not affect values in the calling method. When a variable ceases to exist at the end of a method, programmers say the variable "goes out of scope." A variable's scope is the part of a program in which a variable exists and can be accessed using its unqualified name.

Q2) Normally, you declare constructors to be ____________________ so that other classes can instantiate objects that belong to the class.

Answer: public

Q3) When creating a method that requires multiple parameters, why would a programmer need to understand a method's signature, and why must a method call match the called method's signature?

Answer: The line of code to call the method would appear as follows: practiceWithCalls();

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

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) It is a convenience to be able to use one reasonable name for ____ that are functionally identical except for argument types.

A) arguments

B) classes

C) tasks

D) packages

Q2) When calling this() from a constructor, it must be the ____ statement within the constructor.

A) first

B) ending C) second D) indented

Q3) When you ____________________ methods, you risk creating an ambiguous situation-one in which the compiler cannot determine which method to use.

Q4) What does it mean when a variable overrides another variable? Describe the process of declaring variables in methods and memory locations.

Q5) A(n) ____________________ is simply a folder that provides a convenient grouping for classes.

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

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) public class Student

{ private int studentNum; private int studentScore; public int MAX_NUM = 500; public int MAX_SCORE = 100; Student(int num, int score)

{ }

Decision making can be used to control the allowed values in an object's fields. In the above code, the Student class contains two fields that hold a student number and a score. A constructor accepts values for these fields as parameters. Write the code between the curly brackets that will determine whether the value of num is less than the MAX_NUM constant. If true, assign the value of num to studentNum. Otherwise, assign the value of MAX_NUM to the studentNum. Then check if the value of score is less than or equal to MAX_SCORE. If true, assign the value of score to studentScore. Otherwise, assign 0 to studentScore.

Q2) What is wrong with the following statement? How could you correct it?

if(payRate < 5.85 && payRate > 60) System.out.println("Error in pay rate");

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) On many keyboards, the Break key is also the ____ key.

A) Pause

B) Esc

C) Delete

D) Ctrl

Q2) while(10 > 1)

{ System.out.println("Enter a new value");

}

Identify the problem that exists in the above code.

Q3) Loop control variables can be evaluated at the start or the end of the loop. Describe both pretest loops and posttest loops. How do do while loops execute?

Q4) The ____________________ loop is the posttest loop used in Java.

Q5) A(n) ____ loop is a special loop that is used when a definite number of loop iterations is required.

A) while

B) for

C) else

D) do while

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) Takes a String argument and returns its double value

A)parseDouble()

B)toLowerCase()

C)substring()

D)String variable

E)append()

F)buffer

G)setLength()

H)indexOf()

I)insert()

Q2) The methods of the Character class that begin with ____ return a character that has been converted to the stated format.

A) is B) to C) for D) in

Q3) Explain what is needed to declare a String variable and provide an example.

Q4) The ____________________ method requires an integer argument that indicates the position of the character at that position, starting at 0.

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) public static int[] sampleArray()

{ int studentScores = {72, 91, 83};

Using the above code, write the statement that will return the array name.

Q2) How would you use a method that belongs to an object that is part of the array? Use an example and demonstrate with Java code.

Q3) Since an array name is a reference, you are able to use the = operator for assigning and the == operator for comparisons.

A)True

B)False

Q4) The following statement declares an array: int[] increaseValues = new int[5]

final int PLUSTWO = 2;

Create a loop that will add 2 to every array element. Use a symbolic constant named PLUSTWO and use the length field in the loop that will contain the number of elements in the array.

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

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

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) Regarding enumerations, the ____ method returns an array of the enumerated constants.

A) valueOf

B) values

C) ordinal

D) toArray

Q2) The Arrays class ____________________ method sorts the specified array into ascending order.

Q3) Programmers often refer to a ____ search as a "divide and conquer" procedure.

A) bubble

B) binary

C) division

D) split

Q4) double[][] empSales = new double[5][]; The above statement declares a(n) ____ array.

A) insertion

B) sort

C) ragged

D) boolean

Q5) What are some of the advantages of creating an enumeration type?

Page 11

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

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) An advantage to making a method ____________________ is that the compiler knows there will be only one version of the method.

Q2) When you create parent and child classes of your own, the child classes use ____ constructors.

A) two

B) three

C) four

D) six

Q3) If jrStudent is an object of Student, which of the following statements will result in a value of true?

A) Student = instanceof jrStudent

B) jrStudent instanceof Student

C) instanceof Student = jrStudent

D) Student instanceof jrStudent

Q4) An error is generated by the compiler when you attempt to override a static method with a nonstatic method.

A)True

B)False

Q5) The term ____________________ means "many forms."

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) The Object class ____ method converts an Object into a String that contains information about the Object.

A) equals()

B) setType()

C) toString()

D) speak()

Q2) Contains the Object class

A)dynamic method binding

B)collision

C)GregorianCalendar

D)multiple inheritance

E)equals() method

F)-d option

G)java.lang

H)public, static, and final

I)interface

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

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

Q5) In the Java programming language, a package or class library is often delivered to users as a(n) ____________________ file.

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

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) If a method throws an exception that it will not catch but that will be caught by a different method, you must also use the keyword ____ followed by an Exception type in the method header.

A) finally

B) try

C) catch

D) throws

Q2) The memory location known as the ____________________ is where the computer stores the list of method locations to which the system must return.

Q3) Assertions are meant to be helpful in the ____ stage of a program.

A) development

B) testing

C) production

D) modeling

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

Q5) The ____________________ class comprises less serious errors that represent unusual conditions that arise while a program is running and from which the program can recover.

Q6) What is a finally block and how would a programmer use it?

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) You can create a writeable file by using the Files class ____ method.

A) getOutputStream()

B) newOutputStream()

C) newFileOutputStream()

D) fileOutputStream()

Q2) When you store records in a file, it is often more useful to be able to access the 34th record rather than the 34th byte.

A)True

B)False

Q3) InputStream is a child of FileInputStream.

A)True

B)False

Q4) Placing a file in the ____ directory of your storage device is equivalent to tossing a loose document into a drawer.

A) root

B) path

C) back

D) loose

Q5) Briefly describe the Path class in Java.

Q6) How can you categorize files by the way they store data?

Page 15

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

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) Popup windows that can help a user understand the purpose of components in an application

A)point size

B)layout manager

C)lightweight components

D)window decorations

E)editable

F)tool tips

G)heavyweight components

H)fonts

I)event handler

Q2) Assume you have declared a JFrame named welcomeFrame. Write the statement to set the welcomeFrame object's size to 300 pixels horizontally by 110 pixels vertically. Create a second statement to set the JFrame's title to display the text "My Sized Frame".

Q3) A ____ is a Component the user can click with a mouse to make a selection.

A) JCheckBox

B) JButton

C) JLabel

D) JComboBox

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

Page 16

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) Each JMenu can contain options, called JMenuItems, or can contain submenus that are ____.

A) JMenuBars

B) JMenuChildren

C) JSubMenus

D) JMenus

Q2) The default size of a component

A)GridBagLayout

B)JScrollPane

C)JPanel

D)glass pane

E)GridLayout

F)action key

G)Color class

H)MouseEvent

I)preferred size

Q3) A(n) _________________________ is a tree of components that has a top-level container as its root (that is, at its uppermost level).

Q4) ____________________ are lists of user options; they are commonly added features in GUI programs.

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

Q2) If a window is 200 pixels wide by 100 pixels tall, you can place a Button named pressMe in the approximate center of the window with which of the following statements?

A) pressMe.setLocation(100,50);

B) pressMe.setPosition(100,50);

C) pressMe.setLocation(200,100);

D) pressMe.setPosition(200,100);

Q3) The Color class contains ____ constants.

A) 3

B) 9

C) 13

D) 16

Q4) You use the ____________________ method in statements to add points to a polygon.

Q5) What parameters does the copyArea() method require?

Page 18

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

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) How do you view an applet?

Q2) How is an applet like a Java application?

Q3) The ___________________ method is always called after the init() and start() methods execute.

Q4) Executes again every time the applet becomes active after it has been inactive

A)current version of HTML

B)init()

C)start()

D)HTML

E)Applet Viewer

F)tags

G)multimedia

H)applet

I)play()

Q5) By calling ____ in an applet, you get a URL object that represents the folder in which the applet's class file is stored.

A) getFile()

B) getClass()

C) getDocBase()

D) getCodeBase()

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

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.