Programming Principles Exam Practice Tests - 620 Verified Questions

Page 1


Programming Principles

Exam Practice Tests

Course Introduction

This course offers an introduction to the foundational principles of computer programming, focusing on problem-solving, algorithmic thinking, and the basic constructs of programming languages. Students will learn about variables, data types, control flow (such as conditionals and loops), functions, and basic data structures. By working through hands-on exercises and projects, learners will develop the skills necessary to write clear, efficient, and maintainable code. Emphasis is placed on both the theoretical concepts and practical applications, equipping students to approach programming challenges with confidence and analytical rigor.

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) The original name for Java was

A) *7.

B) Oak.

C) HotJava.

D) Elm.

Answer: B

Q2) Suppose you are at an operating system command line, and you are going to use the following command to compile a program: javac MyClass.java

Before entering the command, you must

A) close all other Windows on your computer system.

B) make sure you are in the same directory or folder where the MyClass.java file is located.

C) execute the java.sun.com program.

D) save the program with the .comp extension.

Answer: B

Q3) Logical errors are mistakes that cause the program to produce erroneous results. 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

40 Verified Questions

40 Flashcards

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

Sample Questions

Q1) When you call one of the Scanner class's methods to read a primitive value, such as nextInt or nextDouble, and then call the nextLine method to read a string, an annoying and hard-to-find problem can occur.

A)True

B)False Answer: True

Q2) Programming style includes techniques for consistently putting spaces and indentation in a program so visual cues are created.

A)True

B)False Answer: True

Q3) This is a value that is written into the code of a program.

A) Literal

B) Assignment statement

C) Operator

D) Variable Answer: A

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) In the blueprint/house analogy, think of a class as a blueprint that describes a house and ________ as instances of the house built from the blueprint.

A) methods

B) fields

C) objects

D) attributes

Answer: C

Q2) UML diagrams do not contain A) fields.

B) methods.

C) class names.

D) object names.

Answer: D

Q3) The scope of a local variable is A) inside the parentheses of a method header.

B) the method in which they are defined.

C) inside the class, but not inside any method.

D) the entire class.

Answer: B

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

Q2) A flag may have the values

A) defined or undefined.

B) of any range of numbers.

C) true or false.

D) of any Unicode character.

Q3) What will be displayed after the following statements are executed?

Int hours = 30;

Double pay, payRate = 10.00; Pay = hours <= 40 ? hours * payRate : hours * payRate * 2.0; System.out.println(pay);

A) 300.0

B) 600.0

C) 400.0

D) The code contains an error and will not compile.

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

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) In all but rare cases, loops must contain within themselves

A) nested loops.

B) a way to terminate.

C) arithmetic operators.

D) if statements.

Q2) Assuming that inputFile references a Scanner object that was used to open a file, which of the following statements will read an int from the file?

A) int number = inputFile.next();

B) int number = inputFile.integer();

C) int number = inputFile.readInt();

D) int number = inputFile.nextInt();

Q3) Assume that inputFile references a Scanner object that was used to open a file. Which of the following while loops shows the correct way to read data from the file until the end of the file is reached?

A) while (inputFile.nextLine == " ")

B) while (inputFile != null)

C) while (!inputFile.EOF)

D) while (inputFile.hasNext())

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

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) You cannot use the fully-qualified name of an enum constant for A) a case expression.

B) an argument to a method.

C) a boolean expression.

D) All of the above.

Q2) Overloading is

A) writing a method that does too much processing.

B) writing a program that is too large to fit in memory.

C) having two or more methods with the same name, but different signatures.

D) having two or more methods with the same signature.

Q3) You can declare an enumerated data type inside of a method.

A)True

B)False

Q4) ________ is the term for the relationship created by object aggregation.

A) "Has a"

B) Inner class

C) "Is a"

D) One-to-many

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

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) When an array of objects is declared, but not initialized, the array values are set to 0.

A)True

B)False

Q2) To return an array of long values from a method, use this as the return type for the method.

A) long[ARRAY_SIZE]

B) array

C) long[]

D) long

Q3) The sequential search algorithm

A) returns 1 if the value being search for is found, otherwise it returns -1.

B) requires the array to be in ascending ordered.

C) uses a loop to sequentially step through an array, starting with the first element.

D) All of the above

Q4) The Java compiler does not display an error message when it processes a statement that uses an invalid subscript.

A)True

B)False

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) Most of the String comparison methods are case sensitive.

A)True

B)False

Q2) What will be displayed after the following statements are executed?

StringBuilder strb = new StringBuilder(12);

Strb.append("The cow ");

Strb.append("jumped over the ");

Strb.append("moon."); System.out.println(strb);

A) The cow jumped over the moon.

B) The cow jumped over the Moon.

C) The cow jump

D) 12The cow jumped over the moon.

Q3) Which of the following statements converts an int variable named number to a string and stores the value in the String object variable named str?

A) String str = Integer.toString(number);

B) String str = number.Integer.toString(str);

C) String str = integer(number);

D) String str = integer.toString(number);

To view all questions and flashcards with answers, click on the resource link above. Page 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) Because the subclass is more specialized than the superclass, it is sometimes necessary for the subclass to replace inadequate superclass methods with more suitable ones.

A)True

B)False

Q2) Which of the following statements correctly specifies two interfaces?

A) public class ClassA implements [Interface1, Interface2]

B) public class ClassA implements (Interface1, Interface2)

C) public class ClassA implements Interface1 | Interface2

D) public class ClassA implements Interface1, Interface2

Q3) You show inheritance in a UML diagram by connecting two classes with a line that has an open arrowhead that points to the subclass.

A)True

B)False

Q4) Because every class directly or indirectly inherits from the Object class, every class inherits the Object class's members.

A)True

B)False

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

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) To write data to a binary file, you create objects from the following classes:

A) File and Scanner.

B) BinaryFileWriter and BinaryDataWriter.

C) FileOutputStream and DataOutputStream.

D) File and PrintWriter.

Q2) If a program does not handle an unchecked exception, what is the result?

A) The program must handle the exception.

B) The program is halted and the default exception handler handles the exception.

C) The exception is ignored.

D) A compiler error will occur.

Q3) When you write a method that throws a checked exception, you must A) override the default error method.

B) ensure that the error will occur at least once each time the program is executed. C) have a throws clause in the method header.

D) use each class only once in a method.

Q4) 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. Page 12

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) The process of connecting an event listener object to a component is called ________ the event listener.

A) coupling

B) priming

C) registering

D) installing

Q3) Swing components are part of the javax.swing package.

A)True

B)False

Q4) ________, which may appear alone or in groups, allow the user to make yes/no or on/off selections.

A) Active panels

B) Toggle buttons

C) Radio buttons

D) Check boxes

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) When you create an instance of the JList class,

A) the text field will be editable.

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

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

D) you must indicate a selection mode.

Q2) What does the following statement do?

JTextArea textField = JTextArea(message, 25, 15);

A) It creates a text area with 25 rows and 15 columns that will initially display the text "message."

B) It creates a text area with 25 columns and 15 rows that will initially display the text stored in the String object referenced by message.

C) It creates a text area with 25 columns and 15 rows that will initially display the text stored in the JTextArea object referenced by textField.

D) It creates a text area with 25 rows and 15 columns that will initially display the text stored in the String object referenced by message.

To view all questions and flashcards with answers, click on the resource link above. Page 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) To make a Web page, you create a text file that contains HTML instructions, which are known as ________, as well as the text that should be displayed on the Web page.

A) markups

B) hypertext

C) labels

D) tags

Q2) Which of the following statements would you write in an HTML document to display the text "History" as a level one header?

A) &lt;h1&gt;History&lt;/h1&gt;

B) &lt;title&gt;History&lt;/title&gt;

C) &lt;h6&gt;History&lt;/h6&gt;

D) &lt;head&gt;History&lt;/head&gt;

Q3) In HTML, the &lt;h1&gt;&lt;/h1&gt; tag marks a document's head section, whereas the &lt;head&gt;&lt;/head&gt; tag marks a header, which is large bold text.

A)True

B)False

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

Page 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) Which of the following does not belong in a JavaFX scene graph?

A) trunk node

B) branch node

C) leaf node

D) root node

Q2) This is a markup language that describes the components in a JavaFX scene graph.

A) SGML

B) HTML

C) XML

D) FXML

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

Q4) In a scene graph, the root node and branch nodes can have children, but leaf nodes cannot.

A)True

B)False

Page 16

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

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) A problem can be solved recursively if it can be broken down into successive smaller problems that are identical to the overall problem.

A)True

B)False

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

Q3) The number of times that a method calls itself is known as

A) the call count.

B) the cyclic identity.

C) the method heap.

D) the depth of recursion.

Q4) This occurs when method A calls method B, which in turn calls method A.

A) dynamic recursion

B) linear recursion

C) direct recursion

D) indirect recursion

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) A qualified column name takes the following form:

A) ColumnName.TableName

B) TableName.ColumnName

C) RowName.TableName

D) DatabaseURL.ColumnName

Q2) Which Statement interface method should be used to execute an INSERT statement?

A) executeUpdate

B) executeStatement

C) executeQuery

D) executeSQL

Q3) What SQL operator can be used to disqualify search criteria in a WHERE clause?

A) AND

B) NOT

C) EXCLUDE

D) NOR

Q4) SQL statements that are stored in the DBMS are called resident queries.

A)True

B)False

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.