Skip to main content

Introduction to Programming Exam Solutions - 758 Verified Questions

Page 1


Introduction to Programming Exam Solutions

Course Introduction

Introduction to Programming provides students with foundational knowledge and practical skills in computer programming. This course covers basic programming concepts such as variables, data types, control structures, functions, and arrays, using a high-level programming language. Through hands-on exercises and projects, students learn to write, test, and debug simple programs. Emphasis is placed on problem-solving techniques, algorithm development, and logical thinking to prepare students for further studies in computer science and related fields.

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

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) List the primitive data types Java supports.Indicate the kind of values each type can store.

Answer: boolean ,true or false char,single Unicode character byte,integer (8 bits) short,integer (16 bits) int,integer (32 bits) long,integer (64 bits) float,floating-point number (32 bit IEEE 754) double,floating-point number (64 bit IEEE 754)

Q2) What does the String method trim()do? Give an example of its use.

Answer: The string method trim removes leading and trailing white space,as well as the tab and new-line character from String objects.For example,the following is an invocation of trim(): String s = userInput.trim(); where s represents the new String with no white space,tab or new-line characters.

Q3) What is the value of the variable c in the statements that follow?

String phrase = "Make hay while the sun is shining."; Char c = phrase.charAt(10);

A)w

B)h

C)i

D)None of the above

Answer: B

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 Java package includes the class Scanner?

A)awt

B)swing

C)io

D)util

Answer: D

Q2) The Java method printf is based on the ________ language.

A)Pascal

B)C++

C)C

D)ADA

Answer: C

Q3) The Scanner class has a method next that allows an entire line of string text to be read.

A)True

B)False

Answer: False

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

Page 4

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

Q2) Common loop errors are:

A)Off-by-one

B)Infinite loops

C)Both a and b

D)None of the above

Answer: C

Q3) The ____________ operator has the highest precedence.

A)*

B)dot

C)+=

D)decrement

Answer: B

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

Page 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) The modifier private means that an instance variable can be accessed by name outside of the class definition.

A)True

B)False

Q2) Discuss the public and private modifiers in context of methods and instance variables.

Q3) When you want the parameters in a method to be the same as the instance variables you can use the _____ parameter.

A)String

B)hidden

C)default

D)this

Q4) Write a driver program to test your Student class created in question #14.

Q5) Java supports operator overloading.

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) What is the purpose of the new operator?

Page 6

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

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) An example of secondary memory is:

A)RAM

B)ROM

C)hard disk

D)all of the above

Q2) Wrapper classes are provided for all primitive Java types except Boolean.

A)True

B)False

Q3) How many bytes are contained within 16-bits,32-bits,64-bits?

Q4) A class invariant is a statement that is always true for every object of the class.

A)True

B)False

Q5) A main method can be placed inside a class definition.

A)True

B)False

Q6) Explain how a package is named in Java.

Q7) Explain in detail how main memory works.

Q8) Write ONE Java statement that computes and displays a random number between 1 and 25.

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) Arrays are objects that are created with new just like class objects.

A)True

B)False

Q3) Partially filled arrays require:

A)a variable to track the number of array positions used

B)the use of local variables

C)the use of global variables

D)all of the above

Q4) Declare and create a multidimensional array to hold the first and last names of 10 people.

Q5) A type of array in which different rows can have different number of columns is called a/an:

A)partially filled array

B)ragged array

C)initialized array

D)none of the above

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

Page 8

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

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) A super class is also called a

A)derived class

B)dominant class

C)sub class

D)base class

Q3) Create a test driver to test the functionality of your Rectangle class created in number 14 above.

Q4) A constructor for a derived class begins with an invocation of a constructor for the base class.

A)True

B)False

Q5) Explain the modifiers public,protected and private.

Q6) Define a derived class to represent an alarm clock.Use the Clock class,created in number 2 above,as your base class.

Q7) Create a class to represent a Rectangle.Your class should contain instance variables for length and width,as well as member method to calculate the area and perimeter.

Q8) What is an "is a" relationship? How does it apply to the world of objects?

Q9) Explain what a call to super()does in a constructor of a derived class.

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) Derive a class named Dress Shoes from the base class created in number 9 above.

Q2) A class with no abstract methods is called a A)concrete class

B)encapsulated class

C)abstract class

D)private class

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

Q4) Early binding enables the compiler to be more efficient.

A)True

B)False

Q5) Assigning an object of an ancestor class to a descendent class is called:

A)static binding

B)dynamic binding

C)upcasting

D)downcasting

Q6) Why should the instanceOf operator be used in conjunction with downcasting?

Q7) Draw an inheritance hierarchy to represent a shoe object.The base class should have derived classes of Dress Shoes,Tennis Shoes and Boots.

Page 10

Q8) Override the clone method inherited in the Tennis Shoes class created in number 11 above.

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

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) Revise the program in number 8 above to use a try/catch block to handle the IOException.

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

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

A)final

B)finally

C)catch

D)none of the above

Q4) In event-driven programming,sending an event is called firing the event.

A)True

B)False

Q5) Exceptions that are subject to the catch or declare rule are called:

A)Checked exceptions

B)Unchecked exceptions

C)Fatal exceptions

D)All of the above

11

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) The methods of the scanner class do not behave the same when reading from a text file as they do when used to read from the keyboard.

A)True

B)False

Q2) The stream that is automatically available to your Java code is:

A)System.out

B)System.in

C)System.err

D)all of the above

Q3) Write a Java statement that creates an output stream to append data to a file named autos.txt.

Q4) Write a complete Java program using a BufferedReader object that opens a file named autos.txt and displays each line to the screen.

Q5) The File class contains methods that allow you to check various properties of a file.

A)True

B)False

Q6) Use the output stream to the file autos.txt created above in number 2 to write the line "Mercedes" to the file.

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

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) In a quick sort algorithm,a value called a splitting value is an arbitrarily selected value from the array to sort.

A)True

B)False

Q2) Define pseudocode.

Q3) An example of a container is a/an:

A)array

B)vector

C)linked list

D)all of the above

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

A)public access

B)protected access

C)private access

D)package access

Q5) A container is a class whose objects hold multiple pieces of data.

A)True

B)False

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

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 13

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) A common use of inner classes is :

A)clean up

B)set up

C)helper

D)all of the above

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

A)True

B)False

Q3) The Comparable interface is in the ______________ package.

A)java.util

B)java.io

C)java.awt

D)java.lang

Q4) When using the clone method from an inherited base class you should account for a _________ exception.

A)CloneNotFoundException

B)CloneEmptyException

C)CloneNotSupportedException

D)CloneNotEmptyException

Q5) What are two advantages to using inner classes?

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

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) Class and method definitions that include parameters for types are called:

A)generics

B)ArrayList

C)Base type

D)None of the above

Q2) You can use any primitive type as the base type of an ArrayList class.

A)True

B)False

Q3) To use the Java class ArrayList,you must import the package:

A)java.awt

B)java.io

C)java.util

D)java.container

Q4) To place an element in an ArrayList position for the first time,you usually use the method:

A)put()

B)set()

C)add()

D)place()

Q5) What are the three main disadvantages of an ArrayList?

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

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) Redraw the diagram created in number 4 above after deleting the head node.

Q2) What is the binary search tree storage rule?

Q3) A _________________ maps a data value such as a String into a number:

A)recursive function

B)key function

C)hash function

D)none of the above

Q4) A _____________ copy of an object is a copy that has references in common with the original object.

A)bit copy

B)deep copy

C)shallow copy

D)none of the above

Q5) In Java,you indicate the end of a linked list be setting the link instance variable of the last node in the linked list to __________.

A)0

B)-1

C)1

D)null

Q6) following values in the given order: 7,10,5,12,1,3,9.

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

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) Memory management methods of the vector class include all of the following except:

A)remove()

B)trimToSize()

C)capacity()

D)size()

Q2) Write a method named displayList()that has one parameter of type Vector and has a return value of void.The method uses an iterator to display the contents of the Vector.

Q3) The hasNext()method of the Iterator interface has a return value of:

A)byte

B)int

C)boolean

D)none of the above

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

A)Collection< T >

B)Set< T >

C)List< T >

D)All of the above

Q5) Compare and contrast vectors and arrays.

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

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) A button fires events know as:

A)static events

B)passive events

C)dynamic events

D)action events

Q2) The getText()method of a JTextField object returns an object of type:

A)Double

B)Integer

C)Boolean

D)String

Q3) A _____________ is an object that is a simple container class that groups other objects.

A)JPanel

B)JMenu

C)JButton

D)JTextArea

Q4) What are three common objects you must deal with when using a Swing container class?

Q5) Write a Java statement to create a menu with the title "Drawing Template".

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

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

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) An imaginary _____________ is used for drawing all shapes on the screen.

A)bounding box

B)view port

C)container

D)none of the above

Q2) When using scroll bars,the text is viewed through a ______________ that shows only part of the text at a time.

A)view port

B)text area

C)all of the above

D)none of the above

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

A)discrete

B)concrete

C)abstract

D)none of the above

Q4) A view port shows only part of the text at one time.

A)True

B)False

Q5) Explain the Java coordinate system for graphic objects.

Page 19

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

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) ____________ refers to a framework that facilitates software building by connecting software components from diverse sources.

A)JavaBeans

B)Threads

C)SQL

D)all of the above

Q2) The Java language does not support multithreading.

A)True

B)False

Q3) Java's Thread class is in the ____________ package.

A)java.util

B)java.thread

C)java.lang

D)javax.swing

Q4) An InterruptedException is a checked exception.

A)True

B)False

Q5) A thread's start method invokes the thread's run method.

A)True

B)False

Page 20

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 is the value returned when the integer 5 is the argument to the factorial method?

A)15

B)50

C)100

D)120

Q2) What is an activation record?

Q3) Write an iterative method to compute the power of x<sup>n</sup> for non-negative n.

Q4) Infinite recursion:

A)will happen when there is no base case

B)will not happen when there is a base case

C)will not happen if we use subproblems

D)none of the above

Q5) Pick the best answer

A)Recursive methods may include a recursive call

B)Recursive methods may not use iteration

C)Recursive methods must include a recursive call

D)none of the above

Q6) What is a stack overflow?

21

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

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) Images can be embedded within HTML pages.

A)True

B)False

Q2) HTML is a high-level language.

A)True

B)False

Q3) Applets do not normally have constructors.The ___________ method performs the initialization of instance variables.

A)setJMenuBar()

B)init()

C)paint()

D)close()

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

Q5) Create an HTML block that will display "Absolute Java" in the largest standard heading.

Q6) The class ___________ converts a digital picture to an icon for us in an applet.

A)ImageIcon

B)JAppletIcon

C)IconImage

D)IconJApplet

Page 22

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 Exam Solutions - 758 Verified Questions by Quizplus - Issuu