Programming Fundamentals Final Test Solutions - 758 Verified Questions

Page 1


Programming Fundamentals

Final Test Solutions

Course Introduction

Programming Fundamentals introduces the foundational concepts and skills necessary for designing and developing computer programs. The course covers essential topics such as variables, data types, control structures (including loops and conditionals), functions, and basic data structures like arrays and lists. Students learn problem-solving strategies, algorithm development, and debugging techniques while writing, testing, and refining code. Emphasis is placed on structured programming principles, code readability, and good software development practices, providing a solid base for advanced study in computer science and related disciplines.

Recommended Textbook

Absolute Java 5th Edition by Walter Savitch

Available Study Resources on Quizplus

20 Chapters

758 Verified Questions

758 Flashcards

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

Chapter 1: Getting Started

Available Study Resources on Quizplus for this Chatper

46 Verified Questions

46 Flashcards

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

Sample Questions

Q1) In Java,Strings are immutable objects.Immutable objects can be changed.

A)True

B)False

Answer: False

Q2) The syntax that declares a Java named constant named SALES_TAX is:

A)double SALES_TAX = 7.50;

B)public double SALES_TAX = 7.50;

C)public static double SALES_TAX = 7.50;

D)public static final double SALES_TAX = 7.50;

Answer: D

Q3) Define high-level languages,machine language and low-level language.Explain how the languages correspond to one another.

Answer: High-level programming languages were designed to be easy for humans to read and use.High-level languages consist of English like statements.Machine language or low-level language is the language that the computer understands directly. The source code created with Java,a high-level language,is compiled or translated into the machine language,or object code.The object code is the program that executes on the computer.

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

Page 3

Chapter 2: Console Input and Output

Available Study Resources on Quizplus for this Chatper

29 Verified Questions

29 Flashcards

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

Sample Questions

Q1) What is whitespace and why is it import when reading input from the keyboard using the Scanner class?

Answer: Whitespace is any string of characters,such as blank spaces,tabs,and line breaks,that prints as whitespace when written on (white)paper.Whitespace servers as delimiters for many of the Scanner class methods.

Q2) The printf method can be used to output multiple formatted values.

A)True

B)False

Answer: True

Q3) Why is echoing user input a good programming practice?

Answer: Echoing input is a technique that is commonly used to allow the user to check their input for accuracy before it is actually sent to the program for processing.This technique reduces the chances of errors in the program.

Q4) Efficiency is lost in importing the entire package instead of importing the classes you use.

A)True

B)False

Answer: False

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

Chapter 3: Flow of Control

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) Discuss the differences between the break and the continue statements when used in looping mechanisms.

Answer: When the break statement is encountered within a looping mechanism,the loop immediately terminates.When the continue statement is encountered within a looping mechanism,the current iteration is terminated,and execution continues with the next iteration of the loop.

Q2) An algorithm is a step-by-step method of solution.

A)True

B)False

Answer: True

Q3) In a switch statement,the choice of which branch to execute is determined by an expression given in parentheses after the keyword switch.

A)True

B)False

Answer: True

Q4) What would be the output of the code in #1 if number was originally initialized to 25?

Answer: The condition evaluated to false!

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

5

Chapter 4: Defining Classes I

Available Study Resources on Quizplus for this Chatper

44 Verified Questions

44 Flashcards

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

Sample Questions

Q1) Add two constructors to the Appointment class created in question #9.Include a default constructor and a constructor to initialize an Appointment to suitable arguments.

Q2) Write a Java method that prints the phrase "Five purple people eaters were seen munching Martians".

Q3) Mutator methods can return integer values indicating if the change of the instance variable was a success.

A)True

B)False

Q4) What is the purpose of the new operator?

Q5) When you give a command to run a Java program,the runtime system invokes the class constructor.

A)True

B)False

Q6) Write a Java class that represents a Student with instance variables name,id,and gpa.Include constructors,accessor,mutator and any facilitator methods you may need.

Q7) Write a method called isEqual that returns a Boolean value.The method compares two integers for equality.

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

Chapter 5: Defining Classes Ii

Available Study Resources on Quizplus for this Chatper

46 Verified Questions

46 Flashcards

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

Sample Questions

Q1) Add a constructor and a copy constructor to the Book class created in question #13.

Q2) Explain how a package is named in Java.

Q3) Explain in detail how main memory works.

Q4) You may use methods of the Math class without an import statement.

A)True

B)False

Q5) Converting from a value of primitive type to a corresponding object of its associated wrapper class is called:

A)Boxing

B)Unboxing

C)Converting

D)Reinstantiating

Q6) Primitive types are reference types.

A)True

B)False

Q7) In a static method,you may use the this parameter either explicitly or implicitly. A)True

B)False

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

Chapter 6: Arrays

Available Study Resources on Quizplus for this Chatper

47 Verified Questions

47 Flashcards

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

Sample Questions

Q1) An array has only one public instance variable,which is named length.

A)True

B)False

Q2) Which of the following initializer lists correctly initializes the indexed variables of an array named myDoubles?

A)double myDoubles[double] = {0.0,1.0,1.5,2.0,2.5};

B)double myDoubles[5] = new double(0.0,1.0,1.5,2.0,2.5);

C)double[] myDoubles = {0.0,1.0,1.5,2.0,2.5};

D)array myDoubles[double] = {0.0,1.0,1.5,2.0,2.5};

Q3) The subscript of the first indexed variable in an array is: A)0

Q4) The correct syntax for accessing the length of an array named Numbers is:

A)Numbers.length()

B)Numbers.length

C)both A and B

D)none of the above

Q5) What are three ways you can use the square brackets [ ] with an array name?

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

Chapter 7: Inheritance

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) What are the different ways in which you can check the class of an Object?

Q2) The keyword extends indicates:

A)encapsulation

B)polymorphism

C)inheritance

D)none of the above

Q3) An object of a derived class has the type of the derived class,and it also has the type of the base class,and more generally,has the type of every one of its ___________ classes.

A)descendant

B)child

C)ancestor

D)sub

Q4) A derived class is a class defined by adding instance variables and methods to an existing class.

A)True

B)False

Q5) Inheritance refers to a very specialized form of a class.

A)True

B)False

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

Chapter 8: Console Input and Output

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) What are the advantages of polymorphism?

Q2) An abstract method serves as a placeholder for a method that must be defined in all derived classes.

A)True

B)False

Q3) Write a decision statement to determine if an object should be downcast.

Q4) The clone method has ________ parameters.

A)zero

B)one C)two D)three

Q5) Downcasting should be used only in situations where it makes sense. A)True

B)False

Q6) What is wrong with the following method definition? public abstract void doSomething(int count)

Q7) Explain the difference between early and late binding.

Q8) Derive a class named Tennis Shoes from the base class created in number 9 above.

Q9) Derive a class named Boots from the base class created in number 9 above.

Q10) Why should the instanceOf operator be used in conjunction with downcasting? Page 10

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

Chapter 9: Exception Handling

Available Study Resources on Quizplus for this Chatper

45 Verified Questions

45 Flashcards

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

Sample Questions

Q1) The execution of a throw statement is referred to as:

A)catching a block

B)trying a block

C)handling an exception

D)throwing an exception

Q2) Use a catch block to display the exception thrown in number two above.

Q3) Write a complete Java program that prompts the user for two nonnegative integer numbers.Your program should handle bad input data.

Q4) The finally block contains code to be executed whether or not an exception is thrown in a try block.

A)True

B)False

Q5) A _________ block executes regardless of whether an exception occurs.

A)final

B)finally

C)catch

D)none of the above

Q6) The compiler does not complain when the catch or declare rule is ignored.

A)True

B)False

Page 12

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

Chapter 10: File IO

Available Study Resources on Quizplus for this Chatper

46 Verified Questions

46 Flashcards

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

Sample Questions

Q1) Write a Java statement to create an input stream to a file named "statistics.dat".

Q2) Write a Java statement to create and open an output stream to a file named autos.txt.

Q3) Create try and catch block that opens a file named statistics.txt for output.Writes the integers 24,55,and 76 to the file,and then closes the file.

Q4) A __________ path name gives the path to a file,starting with the directory that the program is in.

A)relative

B)descendant

C)full

D)complete

Q5) Write a Java statement to create an input stream to the binary file statistics.dat.

Q6) A full path name gives a complete path name,starting from the directory the program is in.

A)True

B)False

Q7) Explain what happens when an output file is opened in Java.

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

Chapter 12: Uml and Patterns

Available Study Resources on Quizplus for this Chatper

22 Verified Questions

22 Flashcards

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

Sample Questions

Q1) Draw a UML inheritance diagram for possible classes used to represent a bank account.

Q2) In a UML class diagram,the sharp (#)indicates:

A)public access

B)protected access

C)private access

D)package access

Q3) Draw a UML class diagram for a class that represents a sphere.

Q4) Define pseudocode.

Q5) The first section of a UML class diagram specifies the:

A)class members

B)class name

C)class methods

D)class modifiers

Q6) The arrowheads in an inheritance diagram point:

A)North

B)South

C)East

D)West

Q7) Draw a UML class diagram for a class that represents a savings account.

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

Chapter 13: Interfaces and Inner Classes

Available Study Resources on Quizplus for this Chatper

32 Verified Questions

32 Flashcards

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

Sample Questions

Q1) The compiler and the run-time system enforces semantics on the Comparable interface.

A)True

B)False

Q2) What are the semantics of the Comparable interface?

Q3) The Comparable interface is in the ______________ package.

A)java.util

B)java.io

C)java.awt

D)java.lang

Q4) Java interfaces are a way of simulating multiple inheritance.

A)True

B)False

Q5) The compareTo method should return _____________ if the calling object equals the parameter.

A)A negative number

B)Zero

C)A positive number

D)Null

Q6) What is an anonymous class?

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

Chapter 14: Generics and the Arraylist Class

Available Study Resources on Quizplus for this Chatper

31 Verified Questions

31 Flashcards

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

Sample Questions

Q1) An ArrayList object has a fixed size.

A)True

B)False

Q2) All of the following are search methods of the ArrayList class except:

A)isEmpty()

B)lastIndexOf()

C)indexOf()

D)contains()

Q3) The compiler option -Xlint is good for debugging.

A)True

B)False

Q4) A class definition can have more than one type parameter.

A)True

B)False

Q5) A generic class can be instantiated as any of the following base types except:

A)Character

B)Array

C)String

D)Double

Q6) Write a Java statement to create an ArrayList to hold 25 integers.

Page 16

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

Chapter 15: Linked Data Structures

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) Given the Node class created in number 6 above,write Java statements to delete a node from the beginning of the list.

Q2) Redraw the diagram created in number 2 above after inserting a node containing Chattanooga,27.6.

Q3) A queue is a last-in/first-out structure.

A)True

B)False

Q4) An iterator is any object that allows you to step through the list one item at a time.

A)True

B)False

Q5) A common exception that occurs when using linked lists is the:

A)NodeOutOfBoundsException

B)NodeEmptyException

C)NullPointerException

D)NullNodeOccurredException

Q6) Redraw the diagram created in number 3 above,after deleting the node containing Chicago.

Q7) Create a generic Node class to represent the linked list depicted in your diagrams above.

Page 17

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

Chapter 16: Collections and Iterators

Available Study Resources on Quizplus for this Chatper

44 Verified Questions

44 Flashcards

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

Sample Questions

Q1) The AbstractSequentialList class provides efficient implementation of sequentially moving through the list at the expense of having inefficient implementation of random access to elements.

A)True

B)False

Q2) If you want a class that implements the List interface and do not need any methods beyond those in the List interface,you can use the ____________ class.

A)Vector< T >

B)LinkedList< T >

C)HashSet< T >

D)TreeSet< T >

Q3) The primary interface/interfaces for a collection class is/are:

A)Collection< T >

B)Set< T >

C)List< T >

D)All of the above

Q4) What is the purpose of the Java Iterator interface?

Q5) Write a Java statement to resize the resulting vector in number 2 above to 100.

Q6) What must you do before adding a primitive type to a vector?

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

Chapter 17: Swing I

Available Study Resources on Quizplus for this Chatper

37 Verified Questions

37 Flashcards

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

Sample Questions

Q1) The actionPerformed method of the ActionListener interface returns a Boolean value.

A)True

B)False

Q2) Events and listeners for menu items are handled in exactly the same way as they are for buttons.

A)True

B)False

Q3) Inheritance indicates a/an ____________ relationship.

A)Is-a

B)Has-a

C)both A & B

D)none of the above

Q4) Write Java statements to add the menu created in number 7 above to the menu bar.

Q5) In event-driven programming,your program determines the order in which things happen.

A)True

B)False

Q6) What is an action listener? What is an action event?

Q7) Explain the model-view-controller pattern when applied to a typical GUI.

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

Chapter 18: Swing II

Available Study Resources on Quizplus for this Chatper

31 Verified Questions

31 Flashcards

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

Sample Questions

Q1) A rounded rectangle is a rectangle whose corners have been replaced by arcs. A)True

B)False

Q2) Write a Java statement to create a scroll pane for a text area named productDescription.

Q3) A window listener must define all the method headings in the WindowListener interface,even if some are trivial implementations.

A)True

B)False

Q4) The Graphics class is a(n)____________ class.

A)discrete

B)concrete

C)abstract

D)none of the above

Q5) Write a Java statement that draws a filled oval at position (150,100)with a height of 100 and a width of 50.

Q6) Write a Java statement to create an image icon for the image heart.gif.

Q7) Set policies for the scroll bar created in number 3 above.

Q8) Explain the Java coordinate system for graphic objects.

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

Chapter 19: Java Never Ends

Available Study Resources on Quizplus for this Chatper

18 Verified Questions

18 Flashcards

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

Sample Questions

Q1) An InterruptedException is a checked exception.

A)True

B)False

Q2) The Java library that supports database connectivity is called:

A)ODBC

B)CDBC

C)MDBC

D)JDBC

Q3) ____________ means that an object has an identity that extends beyond one session.

A)Event handling

B)Introspection

C)Persistence

D)None of the above

Q4) Threads execute in a ___________ fashion.

A)parallel

B)serial

C)complex

D)none of the above

Q5) Discuss the components of the JavaBean model.

Page 21

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

Chapter 11: Recursion

Available Study Resources on Quizplus for this Chatper

43 Verified Questions

43 Flashcards

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

Sample Questions

Q1) What are the two base cases for a recursive binary search algorithm?

Q2) Recursion is:

A)the ability of a program to call itself

B)the ability of a method to call itself

C)the ability of a method to call smaller methods

D)the ability of a method to implement factorials

Q3) What are the criteria you must consider when formulating a recursive solution?

Q4) Explain the concept of divide and conquer.

Q5) Activation records are used to implement recursion.

A)True

B)False

Q6) A method definition that includes a call to itself is said to be recursive.

A)True

B)False

Q7) All recursive methods have a/an ____________ equivalent method.

A)Iterative

B)Selective

C)Inherited

D)None of the above

Q8) What is an activation record?

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

Chapter 20: Applets

Available Study Resources on Quizplus for this Chatper

25 Verified Questions

25 Flashcards

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

Sample Questions

Q1) Create an HTML page for the applet created in number 4 above (the class file is named myApplet.class).

Q2) An applet class is normally defined as a derived class of the class JApplet.

A)True

B)False

Q3) The purpose of the address tag is to contain the e-mail address for contacting the document's maintainer as well as the date that the document was last modified.

A)True

B)False

Q4) URL stands for:

A)Unified Resource Locator

B)Uniform Reader Locator

C)Uniform Resource Locator

D)Uniform Resource Language

Q5) Write an HTML comment containing the phrase "This is a comment."

Q6) Applets do not support JMenus.

A)True

B)False

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

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.