Skip to main content

Programming Fundamentals Exam Answer Key - 981 Verified Questions

Page 1


Programming Fundamentals

Exam Answer Key

Course Introduction

Programming Fundamentals introduces students to the essential concepts and techniques of computer programming. The course covers key topics such as variables, data types, control structures (conditionals and loops), functions, and basic input/output operations. Students learn problem-solving strategies, algorithm development, and the principles of structured programming using a high-level programming language. Through hands-on exercises and assignments, learners gain practical experience in writing, testing, and debugging simple programs, laying a strong foundation for more advanced studies in computer science and software development.

Recommended Textbook

Starting Out with Java From Control Structures through Data Structures 2nd Edition by Tony Gaddis

Available Study Resources on Quizplus

22 Chapters

981 Verified Questions

981 Flashcards

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

2

Chapter 1: Introduction to Computers and Java

Available Study Resources on Quizplus for this Chatper

42 Verified Questions

42 Flashcards

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

Sample Questions

Q1) Java source files end with the .class extension.

A)True

B)False

Answer: False

Q2) Byte code instructions are:

A) Another name for source code

B) Syntax errors

C) Machine code instructions

D) Read and interpreted by the JVM

Answer: D

Q3) A byte is a collection of:

A) Four bits

B) Six bits

C) Eight bits

D) A dollar

Answer: C

Q4) Colons are used to indicate the end of a Java statement.

A)True

B)False

Answer: False

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

53 Verified Questions

53 Flashcards

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

Sample Questions

Q1) Which Scanner class method reads a String?

A) readString()

B) nextString()

C) getString()

D) nextLine()

Answer: D

Q2) The boolean data type may contain values in the following range of values

A) true or false

B) -128 to + 127

C) - 2,147,483,648 to +2,147,483,647

D) - 32,768 to +32,767

Answer: A

Q3) To print "Hello,world" on the monitor,use the following Java statement

A) SystemOutPrintln("Hello,world");

B) System.out.println{"Hello,world"}

C) System.out.println("Hello,world");

D) Print "Hello,world";

Answer: C

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

4

Chapter 3: Decision Structures

Available Study Resources on Quizplus for this Chatper

52 Verified Questions

52 Flashcards

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

Sample Questions

Q1) An important style rule you should adopt for writing if statements is to write the conditionally executed statement on the line after the if statement.

A)True

B)False

Answer: True

Q2) What is the value of ans after the following code has been executed? int x = 40;

Int y = 40;

Int ans = 0;

If (x = y)

Ans = x + 10;

A) 50

B) 80

C) 30

D) No value,this is a syntax error.

Answer: D

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

Page 5

Chapter 4: Loops and Files

Available Study Resources on Quizplus for this Chatper

48 Verified Questions

48 Flashcards

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

Sample Questions

Q1) The do-while loop must be terminated with a semicolon.

A)True

B)False

Q2) Which of the following will open a file named MyFile.txt and allow you to append data to its existing contents?

A) FileWriter fwriter = new FileWriter("MyFile.txt",true);

PrintWriter outFile = new PrintWriter(fwriter);

B) FileWriter fwriter = new FileWriter("MyFile.txt");

PrintWriter outFile = new PrintWriter(fwriter);

C) PrintWriter outfile = new PrintWriter("MyFile.txt",true);

D) PrintWriter outfile = new PrintWriter(true,"MyFile.txt");

Q3) If a loop does not contain within itself a way to terminate,it is called a(n)

A) while loop

B) do-while loop

C) for loop

D) infinite loop

Q4) In a for statement,the control variable can only be incremented.

A)True

B)False

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

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) Which of the following is included in a method call?

A) return type

B) method modifiers

C) parentheses

D) return variable

Q2) All @param tags in a method's documentation comment must

A) end with a */

B) appear after the general description of the method

C) appear before the method header

D) span several lines

Q3) Values stored in local variables

A) are lost between calls to the method in which they are declared

B) retain their values from the last call to the method in which they are declared

C) may be referenced by the calling method

D) may be referenced by any other method,if the method in which they are declared is a public method

Q4) A value-returning method can return a reference to a non-primitive type.

A)True

B)False

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

Chapter 6: A First Look at Classes

Available Study Resources on Quizplus for this Chatper

49 Verified Questions

49 Flashcards

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

Sample Questions

Q1) Instance methods should be declared static.

A)True

B)False

Q2) When an object is created,the attributes associated with the object are called

A) instance fields

B) instance methods

C) fixed attributes

D) class instances

Q3) A constructor is a method that

A) returns an object of the class.

B) never receives any arguments.

C) with the name ClassName.constructor.

D) performs initialization or setup operations.

Q4) Overloading means multiple methods in the same class

A) have the same name,but different return types

B) have different names,but the same parameter list

C) have the same name,but different parameter lists

D) perform the same function

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

Chapter 7: A First Look at Gui Applications

Available Study Resources on Quizplus for this Chatper

49 Verified Questions

49 Flashcards

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

Sample Questions

Q1) In Java,the ability to display splash screens was introduced in Java 6.

A)True

B)False

Q2) What will be the result of executing the following statement? panel.setBorder(BorderFactory.createLineBorder(Color.BLUE,5));

A) The JPanel referenced by panel will have a blue line border that is 5 millimeters thick.

B) The JPanel referenced by panel will have a blue line border that is 5 pixels thick.

C) The JPanel referenced by panel will have a blue line border that is 5 characters thick.

D) The JPanel referenced by panel will have a blue line border that is 5 inches thick.

Q3) The ActionEvent argument that is passed to an action listener's actionPerformed method is the event object that was generated in response to an event.

A)True

B)False

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

9

Chapter 8: Arrays and the Arraylist Class

Available Study Resources on Quizplus for this Chatper

52 Verified Questions

52 Flashcards

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

Sample Questions

Q1) An ArrayList object automatically expands in size to accommodate the items stored in it.

A)True

B)False

Q2) What would be the results of the following code? final int SIZE = 25;

Int[] array1 = new int[SIZE];

// Code that will put values in array1

Int value = 0;

For (int a = 0;a < array1.length;a++)

{

Value += array1[a];

}

A) value contains the highest value in array1

B) value contains the lowest value in array1

C) value contains the sum of all the values in array1

D) This would cause the program to crash

Q3) Objects in an array are accessed with subscripts,just like any other data type in an array.

A)True

B)False

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

Chapter 9: 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/72360

Sample Questions

Q1) The only limitation that static methods have is

A) they can refer to only non-static members of the class

B) they can only be called from static members of the class

C) they must be declared as public methods

D) they cannot refer to non-static members of the class

Q2) When an object is passed as an argument,it is actually a reference to the object that is passed.

A)True

B)False

Q3) The this key word is the name of a reference variable that is available to all static methods.

A)True

B)False

Q4) An instance of a class does not have to exist in order for values to be stored in a class's static fields.

A)True

B)False

Q5) An enumerated data type is actually a special type of class.

A)True

B)False

11

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

Chapter 10: Text Processing and More About Wrapper

Classes

Available Study Resources on Quizplus for this Chatper

49 Verified Questions

49 Flashcards

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

Sample Questions

Q1) The StringBuilder constructor used in the following statement will... StringBuilder str = new StringBuilder(25);

A) give the object,str,25 bytes of storage and store spaces in them

B) give the object,str,25 bytes of storage and not store anything in them

C) give the object,str,25 or more bytes of storage and store spaces in them

D) give the object,str,0 bytes of storage

Q2) What would be the results of executing the following code? StringBuilder str = new StringBuilder(12);

Str)append("The cow");

Str)append(" jumped over the ");

Str)append("moon.");

A) The program would crash

B) str would reference "The cow jump"

C) str would reference "The cow jumped over the "

D) str would reference "The cow jumped over the moon."

Q3) You must call a method to get the value of a wrapper class object.

A)True

B)False

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

Chapter 11: Inheritance

Available Study Resources on Quizplus for this Chatper

49 Verified Questions

49 Flashcards

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

Sample Questions

Q1) In the following statement,which is the interface? public class ClassA extends ClassB implements ClassC

A) ClassA

B) ClassB

C) ClassC

D) Cannot tell

Q2) If a subclass constructor does not explicitly call a superclass constructor,

A) it must include the code necessary to initialize the superclass fields.

B) the superclass fields will be set to the default values for their data types.

C) Java will automatically call the superclass's default or no-arg constructor immediately after the code in the subclass's constructor executes.

D) Java will automatically call the superclass's default or no-arg constructor just before the code in the subclass's constructor executes.

Q3) An abstract class is not instantiated,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.

13

Chapter 12: Exceptions and Advanced File Io

Available Study Resources on Quizplus for this Chatper

46 Verified Questions

46 Flashcards

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

Sample Questions

Q1) When an exception is thrown by a method that is executing under several layers of method calls,a stack trace indicates the method executing when an exception occurred and all of the methods that were called in order go execute that method.

A)True

B)False

Q2) Look at the following code: FileInputStream fstream = New FileInputStream("MyInfo.dat");

DataInputStream inputFile = New DataInputStream(fstream);

This code can also be written as:

A) FileInputStream inputFile = New FileInputStream(new DataInputStream("MyInfo.dat"));

B) DataInputStream inputFile = New DataInputStream(new FileInputStream("MyInfo.dat"));

C) FileInputStream fstream = New DataInputStream("InputFile.txt");

D) DataInputStream inputFile = New DataInputStream("InputFile.txt");

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

14

Chapter 13: Advanced Gui Applications

Available Study Resources on Quizplus for this Chatper

46 Verified Questions

46 Flashcards

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

Sample Questions

Q1) What will display when the following code is executed: JLabel label = new JLabel ("It is a beautiful morning."); Labed.setIcon(SunnyFace.gif);

A) A label with the text "It is a beautiful day." to the left of the SunnyFace image.

B) A label with the text "It is a beautiful day." to the right of the SunnyFace image.

C) A label with the text "It is a beautiful day." below the SunnyFace image.

D) A label with the text "It is a beautiful day." above the SunnyFace image.

Q2) The following statement textList.setSelectionMode( ListSelectModel.SINGLE_INTERVAL_SELECTION);

A) sets the textList component to single selection mode.

B) sets the textList component to ListSelectModel.

C) sets the textList component to single interval selection mode.

D) sets the value of textList to SINGLE_INTERVAL_SELECTION.

Q3) When an item in a Jlist object is selected it generates a(n)

A) action listener event

B) action performed event

C) list selection listener event

D) list selection event

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

15

Chapter 14: Applets and More

Available Study Resources on Quizplus for this Chatper

39 Verified Questions

39 Flashcards

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

Sample Questions

Q1) If you want to make sure that an applet is compatible with all Java-enabled browsers,use Swing components instead of AWT.

A)True

B)False

Q2) What does the tag < p > cause to happen?

A) A double space

B) A paragraph break

C) Indentation for a paragraph

D) Plain text to be displayed

Q3) If a frame component is 300 pixels wide and 200 pixels high,the upper,right-hand corner has (X,Y)coordinates of

A) (0,0)

B) (300,0)

C) (200,300)

D) (299,0)

Q4) Which of the following sound file formats does Java not support?

A) .wav

B) .au

C) .mid

D) Java supports all of the above

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

34 Verified Questions

34 Flashcards

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

Sample Questions

Q1) The Towers of Hanoi is

A) a mathematical game

B) often used in computer science textbooks

C) demonstrates the power of recursion

D) All of the above

Q2) Look at the following pseudocode algorithm. algorithm Test14(int x)

If (x < 8)

Return (2 * x)

Else

Return (3 * Test14(x - 8)+ 8)

End Test14

What value is returned for Test14(16)?

A) 8

B) 16

C) 24

D) 32

Q3) Any problem that can be solved recursively can also be solved iteratively.

A)True

B)False

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

Page 17

Chapter 16: Sorting, Searching, and Algorithm Analysis

Available Study Resources on Quizplus for this Chatper

46 Verified Questions

46 Flashcards

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

Sample Questions

Q1) The two criteria most often used to measure the efficiency of an algorithm are

A) efficiency and style

B) space and time

C) style and time

D) execution and speed

Q2) A basic step is

A) an operation that can be executed within a constant amount of time

B) an operation that is used only in the simplest algorithms

C) one that is implemented in a library package

D) None of the above

Q3) The worst case complexity function f(n)of an algorithm

A) is the maximum execution time measured when a program with n inputs is executed

B) occurs when the load on the system is heaviest

C) is always harder to compute than the average case complexity

D) is the maximum number of basic steps performed in solving a problem instance with input size n

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

18

Chapter 17: Generics

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) The Java notation MyClass< Student > means that

A) the contents of Student are greater than the contents of MyClass

B) the contents of Student are included in the contents of each MyClass object

C) MyClass is a generic class

D) MyClass is a subclass of Student

Q2) A class is generic

A) if it is a subclass of the Object class

B) if it is a superclass of the Object class

C) if it has type parameters

D) if it has method parameters

Q3) The automatic conversion of a primitive type to the corresponding wrapper type when being passed as parameter to a generic class is called

A) type promotion

B) type wrapping

C) autoconversion

D) autoboxing

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

Chapter 18: Collections

Available Study Resources on Quizplus for this Chatper

50 Verified Questions

50 Flashcards

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

Sample Questions

Q1) The concrete classes that implement the List interface are

A) AbstractList,AbstractSequentialList,and List

B) LinkedList,ArrayList,and AbstractList

C) LinkedList,ArrayList,and Vector

D) None of the above

Q2) In a Map object

A) It is possible for a single key to appear more than once,with different values

B) It is possible for a single key to appear more than once,even with the same values

C) It is possible for a single value to appear more than once,with different keys

D) It is possible for a single value to appear more than once,even with the same key

Q3) Which of the following is true?

A) The ListIterator interface is a subinterface of the Iterator interface

B) The ListIterator interface is a superinterface of the Iterator interface

C) The ListIterator interface extends the List interface

D) None of the above

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

Chapter 19: Array-Based Lists

Available Study Resources on Quizplus for this Chatper

20 Verified Questions

20 Flashcards

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

Sample Questions

Q1) Assume an array-based list implemented by a class that uses the fields

String [ ] list; int nElements;

to represent the array of elements,and the number of elements currently stored.Show the code for a method String remove(int index)that removes and returns the element at the given index.The method should throw an appropriately named exception if it cannot return the requested element.

Q2) Assume an array-based list implemented by a class that uses the fields

String [ ] list; int nElements;

to represent the array of elements,and the number of elements currently stored.Show the code for a method String set(int index,String str)that sets the element at the given index to str and returns the element previously stored there.

Q3) Assume an array-based list implemented by a class that uses the fields

String [ ] list; int nElements;

to represent the array of elements,and the number of elements currently stored.Show the code for a constructor that creates a list with a default capacity of 100.

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

21

Chapter 20: Linked Lists

Available Study Resources on Quizplus for this Chatper

36 Verified Questions

36 Flashcards

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

Sample Questions

Q1) A linked list class keeps its elements in the order in which they are added,with the index of an element X being greater than the index of any element added to the list before X.Addition of new elements to such a list can be made more efficient

A) by keeping a reference to the element with the least index

B) by starting at the head,and quickly traversing the list to locate the place where a new element should be added

C) by keeping a reference to the last element added

D) None of the above

Q2) In a typical doubly linked list,a node has

A) a field to store the element,and two references to keep track of two successor nodes

B) a field to store the element,and two references to keep track of successor and predecessor nodes

C) a field to store the element,and two references to keep track of two predecessor nodes

D) either one of A or C

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

Chapter 21: Stacks and Queues

Available Study Resources on Quizplus for this Chatper

36 Verified Questions

36 Flashcards

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

Sample Questions

Q1) The operation for adding an item to a queue is called

A) requeue

B) enqueue

C) dequeue

D) proqueue

Q2) A queue is a container that allows elements to be stored and removed

A) in a last-in-first-out fashion

B) in a first-in-first-out fashion

C) in a first-in-last-out fashion

D) quickly and efficiently

Q3) The stack pull operation

A) increases the capacity of a stack that is about to fill up

B) extracts one element from the stack and returns it

C) brings two stacks together and combines their elements

D) does not exist: There is no such stack operation

Q4) The operation for removing an item from a queue is called

A) enqueue

B) dequeue

C) extract

D) disqueue

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

Chapter 22: Binary Trees, Avl Trees, and Priority Queues

Available Study Resources on Quizplus for this Chatper

45 Verified Questions

45 Flashcards

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

Sample Questions

Q1) An empty binary tree has height

A) -1

B) 0

C) 1

D) None of the above: the height of an empty binary tree is not defined.

Q2) The heap sort method has a worst case complexity function that is in

A) O(log n)

B) O(n.

C) O(n2.

D) O(n log n.

Q3) The length of the longest path from the root of a binary tree to a leaf is called

A) the height of the tree

B) the level of the tree

C) the max-path length of the tree

D) the peak length of the tree

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

Turn static files into dynamic content formats.

Create a flipbook