Skip to main content

Introduction to Programming Chapter Exam Questions - 2169 Verified Questions

Page 1


Introduction to Programming

Chapter Exam Questions

Course Introduction

This course provides a comprehensive introduction to the fundamental concepts and principles of programming using a high-level language such as Python or Java. Students will learn how to design, write, test, and debug simple programs, with a focus on problem-solving, algorithm development, and the use of variables, control structures, functions, and data structures. The course emphasizes computational thinking and provides hands-on experience through practical exercises and projects, equipping students with the essential skills needed for further study in computer science and related fields.

Recommended Textbook

Big Java Late Objects 1st Edition by Cay S. Horstmann

Available Study Resources on Quizplus

24 Chapters

2169 Verified Questions

2169 Flashcards

Source URL: https://quizplus.com/study-set/3769

Page 2

Chapter 1: Introduction

Available Study Resources on Quizplus for this Chatper

96 Verified Questions

96 Flashcards

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

Sample Questions

Q1) Which of the following refers to a collection of programs that a computer executes?

A) Software

B) Assembler

C) Instructions

D) Source code

Answer: A

Q2) Because Java was designed for the Internet, which two of its attributes make it suitable for beginning programmers?

A) Efficiency and portability

B) Safety and security

C) Safety and portability

D) Efficiency and security

Answer: C

Q3) A sequence of steps that is unambiguous, executable, and terminating is called

A) pseudocode

B) an algorithm

C) a logarithm

D) a programming task

Answer: B

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

Page 3

Chapter 2: Fundamental Data Types

Available Study Resources on Quizplus for this Chatper

103 Verified Questions

103 Flashcards

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

Sample Questions

Q1) Which operator is used to concatenate two or more strings?

A) +

B) %

C) &

D) ^

Answer: A

Q2) What is the value of Math.pow(3, 2)?

A) 6

B) 9

C) 8

D) 5

Answer: B

Q3) What is wrong with the following code?

Int count = 2000 * 3000 * 4000;

A) Wrong data type

B) Variable is undefined

C) Integer overflow

D) Illegal expression

Answer: C

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

Page 4

Chapter 3: Decisionseasy

Available Study Resources on Quizplus for this Chatper

99 Verified Questions

99 Flashcards

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

Sample Questions

Q1) Which of the following options checks that city is neither Chicago nor Dallas?

A) if (city != "Chicago" || city != "Dallas")

B) if !(city == "Chicago" || city == "Dallas")

C) if !(city == "Chicago" && city == "Dallas")

D) if (city != "Chicago" || city == "Dallas")

Answer: B

Q2) What is the output of the following code snippet?

Int num = 100; If (num > 100); { Num = num - 10; } System.out.println(num);

A) 90

B) 100

C) 99

D) 101

Answer: A

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

Chapter 4: Loops

Available Study Resources on Quizplus for this Chatper

100 Verified Questions

100 Flashcards

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

Sample Questions

Q1) Which of the following loop(s) should be used when you need to ask a user to enter one data item and repeat the prompt if the data is invalid?

I. for loop

II. while loop III. do loop

A) I only

B) I and II

C) III only

D) II only

Q2) What is the output of the code snippet given below?

Int i = 0;

While (i != 11)

{ System.out.print(" " + i);

I = i + 2;

}

A) No output

B) 0 2 4 6 8

C) 10 12 14 16 18 . (infinite loop)

D) 0 2 4 6 8 10 12 14 . (infinite loop)

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

Page 6

Chapter 5: Methods

Available Study Resources on Quizplus for this Chatper

94 Verified Questions

94 Flashcards

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

Sample Questions

Q1) What is the output of the following code snippet?

Public static int assignPriority(int priority)

{ Return priority + 2;

} Public static void main(String[] args)

{

Int priority = assignPriority(3); System.out.println("Priority: " + priority);

}

A) Priority: 2

B) Priority: 3

C) Priority: 5

D) There is no output because the program does not compile

Q2) When hand-tracing methods, the values for the parameter variables

A) Are the same each time the method is invoked

B) Need not be traced because they are never returned

C) May be undetermined or missing when the method executes

D) Are determined by the arguments supplied in the code that invokes the method

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

Chapter 6: Arrays and Arraylists

Available Study Resources on Quizplus for this Chatper

100 Verified Questions

100 Flashcards

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

Sample Questions

Q1) Why is the following method header invalid?

Public static int[5] meth(int[] arr, int[] num)

A) Methods that return an array cannot specify its size

B) Methods cannot have an array as a return type

C) Methods cannot have an array as a parameter variable

D) Methods cannot have two array parameter variables

Q2) Which one of the following statements is true about passing arrays to a method?

A) By default, arrays are passed by value to a method

B) Arrays, when updated in a called method, are not reflected to the calling method

C) By default, arrays are passed by reference to a method

D) Arrays are passed only if size is specified as another argument

Q3) Consider the following code snippet in Java 6 or later:

String[] data = { "abc", "def", "ghi", "jkl" };

String[] data2 = Arrays.copyOf(data, data.length - 1);

What does the last element of data2 contain?

A) "abc"

B) "def"

C) "ghi"

D) "jkl"

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

Page 8

Chapter 7: Inputoutput and Exception Handling

Available Study Resources on Quizplus for this Chatper

100 Verified Questions

100 Flashcards

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

Sample Questions

Q1) Consider the following code snippet: Scanner in = new Scanner(. . .); While (in.hasNextLine())

{ String input = in.nextLine(); System.out.println(input);

}

Which of the following statements about this code is correct?

A) This code will read in an entire line from the file in each iteration of the loop.

B) This code will read in the entire contents of the file in a single iteration of the loop.

C) This code will read in a single word from the file in each iteration of the loop.

D) This code will read in a single character from the file in each iteration of the loop.

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

9

Chapter 8: Objects and Classes

Available Study Resources on Quizplus for this Chatper

101 Verified Questions

101 Flashcards

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

Sample Questions

Q1) Which of the following statements about class properties is correct?

A) A setter method is used to retrieve the value of a class property.

B) A getter method is used to assign the value of a class property.

C) A setter method is used to assign the value of a class property.

D) You cannot assign values to class properties.

Q2) Which choice indicates that a string variable refers to no string?

A) nil

B) ""

C) null

D) empty

Q3) Which of the following statements using data values in a class is NOT correct?

A) You can use an instance variable's data value in an instance method.

B) You can use the argument of an instance method in that method.

C) You can use a global constant's value in an instance method.

D) You can use the argument of any instance method in any other method.

Q4) A constructor is invoked when ___ to create an object.

A) the class keyword is used

B) the class is defined as public

C) the new keyword is used

D) the class is defined as private

Page 10

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

Chapter 9: Inheritance and Interfaces

Available Study Resources on Quizplus for this Chatper

99 Verified Questions

99 Flashcards

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

Sample Questions

Q1) Consider the following code snippet: Public void deposit(double amount)

{ TransactionCount ++; Super.deposit(amount); }

Which of the following statements is true?

A) This method will call itself.

B) This method calls a public method in its subclass.

C) This method calls a private method in its superclass

D) This method calls a public method in its superclass.

Q2) You are creating a Motorcycle class which is supposed to use an interface named Measurable. Which of the following class declaration statements will accomplish this?

A) public class Motorcycle inherits Measurable

B) public class Motorcycle implements Measurable

C) public class Motorcycle interfaces Measurable

D) public class Motorcycle extends Measurable

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

11

Chapter 10: Graphical User Interfaces

Available Study Resources on Quizplus for this Chatper

54 Verified Questions

54 Flashcards

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

Sample Questions

Q1) Event listeners are often installed as ____ classes so that they can have access to the surrounding fields, methods, and final variables.

A) Inner

B) Interface

C) Abstract

D) Helper

Q2) Which statements will create an editable text field and assign "Your choice" to it?

A) JTextField txt = new TextField("Your choice"); Txt)isEditable(true);

B) JTextField txt = new JTextArea("Your choice "); Txt)isEditable(true);

C) JTextField txt.setText("Your choice "); Txt)setEditable(true);

D) JTextField txt = new JTextField("Your choice "); Txt)setEditable(true);

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

Chapter 11: Advanced User Interfaces

Available Study Resources on Quizplus for this Chatper

91 Verified Questions

91 Flashcards

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

Sample Questions

Q1) When method makeMenuItem is called, how many objects are being created?

Public JMenuItem makeMenuItem(final String menuLabel)

{ JMenuItem mi = new JMenuItem(menuLabel);

Class MyMenuListener implements ActionListener { Public void actionPerformed(ActionEvent

A) 1

B) 2

C) 3

D) 4

E) { DoSomethingElse(); System.out.println(menuLabel); } }

Mi)addActionListener(new MyMenuListener()); Return mi; }

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

Chapter 12: Object-Oriented Design

Available Study Resources on Quizplus for this Chatper

100 Verified Questions

100 Flashcards

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

Sample Questions

Q1) Which of the following would be an appropriate name for a class used in an inventory application?

A) Product

B) InitializeInventoryLevel

C) ResetCurrentInventoryLevel

D) ReceiveNewProducts

Q2) Which of the following code snippets denotes that the Purse class depends on the Wallet class?

A) public class Purse extends Wallet

B) public class Wallet extends Purse

C) public class Wallet

{ Private Purse aPurse;

}

D) public class Purse

{ Private Wallet aWallet;

}

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

Chapter 13: Recursion

Available Study Resources on Quizplus for this Chatper

100 Verified Questions

100 Flashcards

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

Sample Questions

Q1) Consider the getArea method from the textbook shown below. Public int getArea()

{ If (width <= 0) { return 0; } // line #1

Else if (width == 1) { return 1; } // line #2

Else

{ Triangle smallerTriangle = new Triangle(width - 1); // line #3

Int smallerArea = smallerTriangle.getArea(); // line #4

Return smallerArea + width; // line #5

} } Where is/are the terminating condition(s)?

A) line #1

B) line #2

C) lines #1 and #2

D) line #4

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

15

Chapter 14: Sorting and Searching

Available Study Resources on Quizplus for this Chatper

99 Verified Questions

99 Flashcards

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

Sample Questions

Q1) When does quicksort's worst-case run-time behavior occur?

I when the data is randomly initialized in the array II when the data is in ascending order III when the data is in descending order

A) I

B) II

C) III

D) II and III

Q2) When the size of an array increases by a factor of 100, the time required by selection sort increases by a factor of ____.

A) 2,000

B) 5,000

C) 10,000

D) 12,000

Q3) Which sort algorithm is used in the sort method in the Java Arrays class when the array length is less than 7?

A) merge sort

B) quicksort

C) selection sort

D) insertion sort

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

Chapter 15: The Java Collections Framework

Available Study Resources on Quizplus for this Chatper

100 Verified Questions

100 Flashcards

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

Sample Questions

Q1) You need to access values by their position. Which collection type should you use?

A) TreeSet

B) ArrayList

C) Stack

D) Queue

Q2) Which of the following algorithms would be efficiently executed on an ArrayList?

A) add 1 element to the middle of a list with n elements

B) add n / 2 elements to a list with n / 2 elements

C) remove first n / 2 elements from a list of n elements

D) read n / 2 elements in random order from a list of n elements

Q3) Assume that you have declared a queue named myQueue to hold String elements. Which of the following statements will correctly remove an element from myQueue?

A) myQueue.remove();

B) myQueue.get();

C) myQueue.delete();

D) myQueue.pop();

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

17

Chapter 16: Basic Data Structures

Available Study Resources on Quizplus for this Chatper

94 Verified Questions

94 Flashcards

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

Sample Questions

Q1) What type of access does the use of an iterator provide for the elements of a bucket in a hash table?

A) sequential

B) semi-random

C) random

D) sorted

Q2) Complete the following code snippet, which is intended to compress a hash code to become a valid array index:

Int h = x.hashCode();

If (h < 0) { h = -h; }

A) position = arrayLength % h;

B) position = arrayLength / h;

C) position = h / arrayLength;

D) position = h % arrayLength;

Q3) An array list maintains a reference to an array of elements called a ____.

A) buffer

B) tree map

C) hash table

D) bucket

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

Chapter 17: Tree Structures

Available Study Resources on Quizplus for this Chatper

100 Verified Questions

100 Flashcards

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

Sample Questions

Q1) Which of the following statements about inserting a node into a red-black tree is NOT correct?

A) If it is the first node, it must be black.

B) Color the new node red.

C) If the parent of the new node is red, no other actions are required.

D) A double-red result can occur in a left subtree or a right subtree.

Q2) Locating an element in an unbalanced binary search tree takes ____ time.

A) O(n)

B) O(log (n))

C) O(1)

D) O(n<sup>2</sup>)

Q3) A completely filled binary tree with a height of 4 has ____ nodes.

A) 8

B) 12

C) 15

D) 16

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

Chapter 18: Generic Classes

Available Study Resources on Quizplus for this Chatper

78 Verified Questions

78 Flashcards

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

Sample Questions

Q1) Which is the purpose of the &lt;E&gt; element in the class declaration below?

Public class Thing&lt;E&gt;

{ Public Thing() { . . . }

}

A) declares that only instances of E class can be stored

B) it is a type variable

C) it is an instance variable

D) it is a cast

Q2) Which of the following statements about generic methods is correct?

A) A generic method must reside in a generic class.

B) A generic method must have a generic type argument.

C) A generic method must have a generic type parameter.

D) The generic type parameter of a generic method designates the method's return type.

Q3) Which of the following satisfies the wildcard ? super Object?

A) String

B) JComponent

C) Scanner

D) none satisfy this wildcard

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

Chapter 19: Streams and Binary Inputoutput

Available Study Resources on Quizplus for this Chatper

82 Verified Questions

82 Flashcards

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

Sample Questions

Q1) If you write a simple Student class, what must you do in order to write Student objects to an ObjectOutputStream?

A) Code a write method.

B) Make all class variables primitive.

C) Implement Serializable.

D) Implement Streamable.

Q2) Caesar cipher uses a shift of each character by a key with a value between 1 and 255. An a with a shift equal to 3 becomes a d. A z would become a c, wrapping around the alphabet. Which is the encryption of shadow for a key = 3?

A) ukdgry

B) vkdgrz

C) adowsha

D) vjegrz

Q3) The two IO classes used for serialization are _______ and ________.

A) Reader, Writer

B) ObjectInputStream, ObjectOutputStream

C) Scanner, PrintWriter

D) FileReader, FileWriter

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

Chapter 20: Multithreading

Available Study Resources on Quizplus for this Chatper

82 Verified Questions

82 Flashcards

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

Sample Questions

Q1) Insert the statement that would start the following thread. Thread firstThread = new Thread(myRunnable);

A) firstThread.run();

B) firstThread.start();

C) run();

D) start();

Q2) To start a thread, you should first construct an object from a class that implements the ____________ interface.

A) Thread

B) Threadable

C) Run

D) Runnable

Q3) If a thread sleeps after acquiring a _________, it blocks all other threads that want to acquire it.

A) condition

B) signal

C) lock

D) thread

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

Page 22

Chapter 21: Internet Networking

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

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

Sample Questions

Q1) What does the acronym POP stand for?

A) Point to Point

B) Post Office Point

C) Protocol Of Point

D) Post Office Protocol

Q2) What are among the most important pieces of information that must be included in an IP packet?

I. The Internet address of the recipient

II. The URL of the recipient

III. The Internet address of the sender

IV. The port number of the sender

A) I, III, and IV

B) I, II, and III

C) II, III, and IV

D) I, II, III, and IV

Q3) A(n) ____ describes how data for a particular application is transmitted.

A) URL

B) application protocol

C) socket

D) IP address

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

Chapter 22: Relational Databases

Available Study Resources on Quizplus for this Chatper

75 Verified Questions

75 Flashcards

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

Sample Questions

Q1) A ____________ is a reference to a primary key in a linked table.

A) foreign key

B) primary key

C) column headers

D) data type

Q2) What will the following command do?

Java -classpath derby.sql;. ExecSQL database.properties Product.sql

A) It will execute the statements in the database.properties file.

B) It will execute the statements in the derby.sql file.

C) It will execute the statements in the Product.sql file.

D) It will act as an interactive testing tool only.

Q3) The following command will compile a Java program called TestDB:

A) java TestDB.class

B) java TestDB.java

C) javac TestDB.java

D) javac TestDB.class

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

24

Chapter 23: XML

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

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

Sample Questions

Q1) An EMPTY element is:

A) an element that may have zero or more children.

B) an element that has no value.

C) an element whose value is the null string.

D) an element that may not have any children.

Q2) When referencing an external DTD (one not on the current file system), you must supply a(n) ____ for locating the DTD.

A) URL

B) domain name

C) IP address

D) element

Q3) Which of the following statements is correct?

A) XML is an extensible syntax that can be used to specify many different kinds of data.

B) XML has one specific purpose: to describe web documents.

C) XML tells you how to display data.

D) You can always replace XML elements with attributes.

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

25

Chapter 24: Web Applications

Available Study Resources on Quizplus for this Chatper

74 Verified Questions

74 Flashcards

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

Sample Questions

Q1) Suppose a DictionaryBean class has a method String getLanguage(). Which JSF page statement would display the language properly?

A) The language of the dictionary is value="dictionaryBean.getLanguage".

B) The language of the dictionary is #{dictionaryBean.getLanguage}.

C) The language of the dictionary is value="#{dictionaryBean.language}".

D) The language of the dictionary is #{dictionaryBean.language}.

Q2) The user interface of a JSF application is described by ________.

A) a set of HTML-only pages.

B) a set of JSF servers.

C) a set of JSF events.

D) a set of JSF pages.

Q3) A method _________ specifies a bean and a method that should be invoked on the bean.

A) property

B) name

C) expression

D) value

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 Programming Chapter Exam Questions - 2169 Verified Questions by Quizplus - Issuu