Skip to main content

Introduction to Programming Exam Practice Tests - 758 Verified Questions

Page 1


Introduction to Programming Exam Practice Tests

Course Introduction

Introduction to Programming is a foundational course designed to equip students with the essential concepts and skills required to write, analyze, and debug computer programs. Through hands-on exercises and projects, students will learn how to use programming languages like Python or Java to solve real-world problems. Topics include variables, data types, control structures, functions, loops, basic algorithms, and the principles of structured programming. Emphasis is placed on developing logical thinking, problem-solving abilities, and effective coding practices, providing students with a robust platform for further study in computer science and software development.

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,the equal sign is used as the ___________ operator.

A)increment

B)decrement

C)assignment

D)negation

Answer: C

Q2) What is the output produced by the following lines of code? int value1 = 3; int value2 = 4; int result = 0; result = value1++ * value2--; System.out.println("Post increment/decrement: " + result); result = ++value1 * --value2; System.out.println("Pre increment/decrement: " + result);

Answer: Post increment/decrement: 12 Pre increment/decrement: 10

Q3) The modulus operator,%,returns the remainder of integer division. A)True

B)False

Answer: True

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) Write Java statements to apply currency formatting to the number 100.Indicate the package you need to import.

Answer: import java.text.NumberFormat; NumberFormat nfMoney = NumberFormat.getCurrencyInstance(); System.out.println(nfMoney.format(100));

Q3) Which statement or group of statements produces the output: Java programming is fun!

A)System.out.print(Java programming); System.out.print(is fun!);

B)System.out.println(Java programming is fun!);

C)System.out.println("Java programming"); System.out.println(" is fun!");

D)System.out.print("Java programming") System.out.println(" is fun!");

Answer: D

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) The for statement,do while statement and while statement are examples of branching mechanisms.

A)True

B)False

Answer: False

Q2) What is a sentinel value and how is it used?

Answer: A sentinel value is a value that should never be encountered in the input of the program.It is used to control looping mechanisms when the number of repetitions is unknown.When the sentinel value is encountered,the loop terminates.A sentinel value is commonly used with while and do .while statements.

Q3) The equality operator (==)may be used to test if two string objects contain the same value.

A)True

B)False

Answer: False

Q4) Write Java code that uses a for statement to sum the numbers from 1 through 50.Display the total sum to the console.

Answer: int sum = 0; for(int i=1; i <= 50; i++) { sum += i; } System.out.println("The total is: " + sum);

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) Accessor methods:

A)return something equivalent to the value of an instance variable.

B)promotes abstraction

C)both A and B

D)none of the above

Q2) Java supports operator overloading.

A)True

B)False

Q3) Java has a way of officially hiding details of a class definition.To hide details,you mark them as _________.

A)public

B)protected

C)private

D)all of the above

Q4) Inside a Java method definition,you can use the keyword this as a name for the calling object.

A)True

B)False

Q5) Write a Java method that returns the value of PI,where PI = 3.1415926535.

Q6) Define the terms arguments and parameters.How are they different?

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) Create a Java class named Book with instance variables title,author,ISBN,and yearPublished.Include javadoc style comments to describe your interface.Such a class would normally have methods,but you are not required to supply any methods.

Q2) A copy constructor has _________ parameters.

A)zero

B)one

C)two

D)three

Q3) A static method is one that can be used with a _____________.

A)instance variable

B)local variable

C)global variable

D)the class name as a calling object

Q4) You should avoid the use of null as an argument to a method.

A)True

B)False

Q5) Primitive types are reference types.

A)True

B)False

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

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 of chars is the same as a String in Java.

A)True

B)False

Q2) Write a complete Java console application that prompts the user for a series of quiz scores.The user should type -1 to signify that the input of quiz scores is complete.Your program should then average the scores and display the result back to the user.

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

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

Q5) An ArrayIndexOutOfBounds error is a:

A)compiler error

B)syntax error

C)logic error

D)all of the above

Q6) How are arrays tested to see if they contain the same contents?

Q7) Explain what the main methods array parameter,args,is used for.

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) Explain what a call to super()does in a constructor of a derived class.

Q2) If the final modifier is added to the definition of a method,this means:

A)The method may be redefined in the derived class.

B)The method may be redefined in the sub class.

C)The method may not be redefined in the derived class.

D)None of the above.

Q3) What does a derived class automatically inherit from the base class?

A)instance variables

B)static variables

C)public methods

D)all of the above

Q4) In using the keyword this in place of super(),the invocation of this must be the ___________ action taken by the constructor.

A)first

B)last

C)it does not matter

D)none of the above

Q5) Define a derived class to represent an alarm clock.Use the Clock class,created in number 2 above,as your base 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) Downcasting should be used only in situations where it makes sense.

A)True

B)False

Q2) The principals of object oriented programming include:

A)encapsulation

B)inheritance

C)polymorphism

D)all of the above

Q3) Assigning an object of a derived class to a variable of a base class is called:

A)static binding

B)dynamic binding

C)upcasting

D)downcasting

Q4) What is an abstract method?

Q5) Java allows an instance of an abstract class to be instantiated.

A)True

B)False

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

Q7) Implement the base class in the shoe hierarchy in number 8 above.

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

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

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) A ___________ block should immediately follow a try block.

A)try

B)catch

C)fail

D)final

Q2) All exceptions are descendants of the class:

A)Throwable

B)Catchable

C)Tryable

D)Blockable

Q3) Use a catch block to display the exception thrown in number one above.

Q4) What is the purpose of the method getMessage()when used with exception handling?

Q5) Define an exception class called FileNotFoundException.The class should have a constructor with no parameters.If an exception is thrown with this zero-argument constructor,getMessage should return "File Not Found!" The class should also have a constructor with a single parameter of type String.If an exception is thrown with this constructor,then getMessage returns the value that was used as an argument to the constructor.

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

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

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 that creates a stream that provides read/write access to the file named autos.txt.

Q2) Only the classes provided for file output contain a method named close.

A)True B)False

Q3) The method _________ reads a single character from an input stream.

A)readLine()

B)skip()

C)read()

D)close()

Q4) Write a Java statement that creates an output stream to a binary file named statistics.dat.

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

Q6) When your program is finished writing to a file,it should close the stream connected to that file.

A)True B)False

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

Page 12

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

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) An example of a container is a/an:

A)array

B)vector

C)linked list

D)all of the above

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

A)class members

B)class name

C)class methods

D)class modifiers

Q3) The arrowheads in an inheritance diagram point:

A)North

B)South

C)East

D)West

Q4) The second section of a UML class diagram specifies the:

A)class members

B)class name

C)class methods

D)class modifiers

Page 13

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

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) An inner class definition is local to the outer class definition.

A)True

B)False

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

A)A negative number

B)Zero

C)A positive number

D)Null

Q3) A Java interface is an example of:

A)encapsulation

B)abstraction

C)polymorphism

D)all of the above

Q4) An interface specifies the headings and definitions for methods that must be defined in any class that implements the interface.

A)True

B)False

Q5) Why does Java only allow the inheritance of only one base class?

Q6) What are the obligations of a class that implements a specific interface?

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

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

A)True

B)False

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

A)Character

B)Array

C)String

D)Double

Q4) Which is the correct syntax for placing the string "boat" into an ArrayList name recVehicles in position 3 for the first time?

A)recVehicles.set(3,"boat"); B)recVehicles.set("boat",3); C)recVehicles.add(3,"boat"); D)recVehicles.add("boat",3);

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

Q2) What is the result of a preorder traversal of the binary search tree created in question 12 above?

Q3) Draw a diagram of a linked list that contains nodes with data items of type String that contains the name of a city and type double that contains a pollution index.Include an instance variable named head to indicate the beginning of the list.Insert the following nodes: Franklin,15.7,Chicago,23.2,Denver,7.2.

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

A)NodeOutOfBoundsException

B)NodeEmptyException

C)NullPointerException

D)NullNodeOccurredException

Q5) What is the result of an inorder traversal of the binary search tree created in question 12 above?

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) Create a for loop to initially set the values of the vector created in number 1 above to the value of negative 1.0.

Q2) The number of entries that may be added to a HashMap&lt;K,V&gt; object is limited to what is specified as the initial capacity in the constructor for the HashMap&lt;K,V&gt; object.

A)True

B)False

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) A collection is a data structure for holding elements.

A)True

B)False

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

Q6) What is the difference between a vector's size and a vector's capacity?

Q7) &lt;T&gt; is a wildcard used to specify a wide range of parameters.

A)True

B)False

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 menu item is an object of the class:

A)JMenu

B)JMenuBar

C)JMenuItem

D)none of the above

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

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

A)Double

B)Integer

C)Boolean

D)String

Q4) A programming style that uses a signal and response approach to programming is called:

A)Object Oriented Programming

B)Structured Programming

C)Event-driven Programming

D)Bottom-up Programming

Q5) GUIs are windowing interfaces that handle user input and output.

A)True

B)False

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) If the policies for scroll bars are never set then the scroll bars will never be visible.

A)True

B)False

Q2) You can use the Java method ______________ from the Color class to change the drawing color.

A)changeColor

B)getColor

C)setColor

D)useColor

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

A)True

B)False

Q4) Write a Java statement that uses a Graphics object to display "Hello World" at position 50,100.

Q5) All of the following are methods of the class Color except:

A)getRed

B)brighter

C)darker

D)dimmer

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

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) What other programming technique can be combined with sockets so a server can handle requests from multiple clients?

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

A)Event handling

B)Introspection

C)Persistence

D)None of the above

Q3) The sleep method of the Thread class requires one formal parameter that represents the number of:

A)nanoseconds

B)microseconds

C)picoseconds

D)milliseconds

Q4) What are Enterprise JavaBeans?

Q5) Discuss the components of the JavaBean model.

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

A)True

B)False

Q7) What is a JavaBean?

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

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) When defining recursive valued methods you should:

A)Ensure there is no infinite recursion.

B)Ensure each stopping case returns the correct value for that case.

C)Ensure that the final value returned by the method is the correct value.

D)All of the above

Q2) Write an iterative method to compute the factorial of a number.

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

A)True

B)False

Q4) Binary search is a divide and conquer algorithm.

A)True

B)False

Q5) How does the computer system handle a recursive method call?

Q6) When a recursive call is encountered,computation is temporarily suspended; all of the information needed to continue the computation is saved and the recursive call is evaluated.

A)True

B)False

Q7) Write a recursive method to compute the factorial of a number.

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

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

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) The HTML tag used to insert a horizontal line on a page is:

A)< h1 >

B)< href >

C)< hr >

D)< br >

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

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

Q4) HTML is a high-level language.

A)True

B)False

Q5) HTML stands for:

A)Hyperlink Making Language

B)Hyper Markup Language

C)Hypertext Markup Language

D)Homepage Markup Language

Q6) HTML is case sensitive.

A)True

B)False

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

Turn static files into dynamic content formats.

Create a flipbook
Introduction to Programming Exam Practice Tests - 758 Verified Questions by Quizplus - Issuu