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 introduce students to the basic concepts of computer programming. Through hands-on experience and interactive learning, students will learn how to write, analyze, and debug simple programs using a high-level programming language. The course covers essential topics such as variables, data types, control structures, functions, and basic algorithms, providing students with a strong groundwork for further study in computer science and software development. No prior programming knowledge is required, making it an ideal starting point for beginners interested in understanding the logic and structure that underpin computational problem-solving.

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) The hardest kind of error to detect in a computer program is a:

A)Syntax error

B)Run-time error

C)Logic error

D)All of the above

Answer: C

Q2) What is the Java expression for 4a<sup>2</sup> + 2b * c?

A)(4 * a)+ (2 * b)* c

B)(4 * a * a)+ ((2 * b)* c)

C)((4 * a * a)+ (2 * b))* c

D)(4 + a * a)+ ((2 + b)* c)

Answer: B

Q3) Java is an interpreted language.

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) The statement: System.out.printf("%6.2f",597.7231); displays:

A)597.723

B)597.72

C)000597.72

D)None of the above

Answer: B

Q2) What does the following code output?

DecimalFormat percent = new DecimalFormat("0.00%"); System.out.println(percent.format(0.308));

A)3.080%

B)30.80%

C).0308%

D)308.0%

Answer: B

Q3) Write a Java statement to display your name in the console window. Answer: System.out.println("Wally Wonders");

Q4) Write a Java statement to create and initialize a Scanner object named input. Answer: Scanner input = new Scanner(System.in);

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) Write Java code that uses a while loop to print even numbers from 2 through 10. Answer: int evenNumber = 2; while(evenNumber <= 10) { System.out.println(evenNumber); evenNumber += 2; }

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

A)True

B)False

Answer: False

Q4) An if-else statement chooses between two alternative statements based on the value of a Boolean expression.

A)True

B)False

Answer: True

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) A _________ states what is assumed to be true when the method is called.

A)prescript

B)postscript

C)precondition

D)postcondition

Q2) The new operator:

A)allocates memory

B)is used to create an object of a class

C)associates an object with a variable that names it.

D)All of the above.

Q3) A method that performs some action other than returning a value is called a __________ method.

A)null

B)void

C)public

D)private

Q4) Method overloading is when two or more methods of the same class have the same name but differ in number or types of parameters.

A)True

B)False

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) A main method can be placed inside a class definition.

A)True

B)False

Q2) The program included in the Java SDK that allows a programmer to separate the class interface from the class implementation is called:

A)javac

B)java

C)javadoc

D)none of the above

Q3) The String class is a mutable class.

A)True

B)False

Q4) To use a package,the program must contain an import statement that names the package.

A)True

B)False

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

A)True

B)False

Q6) What is the purpose of Java's wrapper classes?

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) The subscript of the first indexed variable in an array is:

A)0

B)1

C)2

D)3

Q2) The individual variables that together make up the array are referred to as:

A)indexed variables

B)subscripted variables

C)elements of the array

D)all of the above

Q3) An array of chars is the same as a String in Java.

A)True

B)False

Q4) Write a Java statement that declares and creates an array of Strings named Breeds.Your array should be large enough to hold the names of 100 dog breeds.

Q5) Java allows you to declare arrays with more than one index.

A)True

B)False

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

Q7) Declare and create a 10 x 10 multidimensional array of doubles.

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

A)derived class

B)dominant class

C)sub class

D)base class

Q2) Write Java statements that compares Objects,O1 and O2,using the getClass()method.

Q3) The call to the base class constructor (super)must always be the last action taken in a constructor definition.

A)True

B)False

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

A)True

B)False

Q5) What is a "has a" relationship?

Q6) What is package access?

Q7) What does the instanceof operator do?

Q8) The keyword extends indicates polymorphism. 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) The method clone has one parameter and should return a copy of the calling object.

A)True

B)False

Q2) Explain the difference between early and late binding.

Q3) The clone method return type is:

A)the same as the cloned object

B)Object

C)String

D)none of the above

Q4) __________ refers to the ability to associate many meanings to one method name by means of the late binding mechanism.

A)Inheritance

B)Encapsulation

C)Polymorphism

D)None of the above

Q5) An abstract class is a class that has some methods without complete definitions.

A)True

B)False

Q6) What is polymorphism and how does it relate to late binding?

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

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) What is the catch or declare rule?

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

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

Q4) A program can catch multiple exceptions.

A)True

B)False

Q5) Revise the program in number 8 above to use a try/catch block to handle the IOException.

Q6) If a method throws an exception,and the exception is not caught inside the method,then the method invocation:

A)terminates

B)transfers control to the catch block

C)transfers control to the exception handler

D)none of the above

11

Q7) Revise the program in number 9 above to throw a NegativeNumberException if the user enters a negative number.

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 File class contains methods that allow you to check various properties of a file.

A)True

B)False

Q2) An ___________ allows data to flow into your program.

A)input stream

B)output stream

C)file name

D)all of the above

Q3) A stream is an object that allows for the flow of data between your program and some I/O device or some file.

A)True

B)False

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) 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 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) UML was designed to be used with structured programming methodology.

A)True

B)False

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

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

A)public access

B)protected access

C)private access

D)package access

Q4) The Adaptor pattern transforms one class into a different class without changing the underlying class.

A)True

B)False

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

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

A)True

B)False

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 class that uses an interface must use the keyword: A)Extends

B)Inherits

C)Super

D)Implements

Q2) Inner classes available outside the scope of their outer class are modified by the keyword: A)Public B)Private

C)Protected

D)Package access

Q3) Any constant variables defined in an interface must be defined as: A)public B)private C)protected

D)package access

Q4) What are two advantages to using inner classes?

Q5) What are the rules of total ordering?

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

Q7) What is an anonymous class?

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) A generic class can be instantiated as any of the following base types except:

A)Character

B)Array

C)String

D)Double

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

A)True

B)False

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

A)isEmpty()

B)lastIndexOf()

C)indexOf()

D)contains()

Q4) Class and method definitions that include parameters for types are called:

A)generics

B)ArrayList

C)Base type

D)None of the above

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

Q6) What is the base type of the ArrayList defined in question number 2?

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 3 above,after deleting the node containing Chicago.

Q2) Making the Node class a private inner class of a linked data structure is an example of:

A)polymorphism

B)encapsulation

C)inheritance

D)all of the above

Q3) Java does not come with a LinkedList library class.

A)True

B)False

Q4) What is the function of the variable head when used with a linked list? What is the data type of the head variable?

Q5) A node contains:

A)data item(s)

B)reference(s)to another node

C)both A and B

D)none of the above

Q6) What is the binary search tree storage rule?

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

Q7) Redraw the diagram created in number 4 above after deleting the head node.

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) An Iterator is an object that allows your code to produce the elements in a vector or other container one after the other,exactly once.

A)True

B)False

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

Q3) The List interface is for collections that allow repetition of elements and do not impose an order on their elements.

A)True

B)False

Q4) The method contains(Object o)of the ArrayList class returns a value of type:

A)int

B)char

C)byte

D)boolean

Q5) To use Java's Vector class,you must import the ___________ package.

A)java.Math

B)java.Exception

C)java.util

D)java.lang

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) One of the main functions of JPanel objects is to subdivide a JFrame (or other container)into different areas.

A)True

B)False

Q2) A JMenu can not be a menu item in another menu.

A)True

B)False

Q3) Write a Java statement to add a title to the window in the GUI created in number 1 above that says "First Window".

Q4) Inheritance indicates a/an ____________ relationship.

A)Is-a

B)Has-a

C)both A & B

D)none of the above

Q5) When using the BorderLayout manager you must specify all five regions. A)True

B)False

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

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

Page 18

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

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) All of the following are methods of the Graphics class except:

A)drawRect

B)fillRect

C)coloredRect

D)fill3DRect

Q2) Java uses a coordinate system whose origin point (0,0)is located at the upper-left corner of the screen area.

A)True

B)False

Q3) An invocation of the Container class method _____________ updates components on the screen.

A)setVisible

B)setLayout

C)update

D)validate

Q4) An imaginary _____________ is used for drawing all shapes on the screen.

A)bounding box

B)view port

C)container

D)none of the above

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) ____________ means that an object has an identity that extends beyond one session.

A)Event handling

B)Introspection

C)Persistence

D)None of the above

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

A)ODBC

B)CDBC

C)MDBC

D)JDBC

Q3) SQL stands for Structured Query Language.

A)True

B)False

Q4) What are Enterprise JavaBeans?

Q5) What other programming technique can be combined with sockets so a server can handle requests from multiple clients?

Q6) Discuss the components of the JavaBean model.

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) What are the two base cases for a recursive binary search algorithm?

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

Q3) What is the value returned when the integer 5 is the argument to the factorial method?

A)15

B)50

C)100

D)120

Q4) What is an activation record?

Q5) Write an iterative method to print a string backwards.

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

Q7) Activation records are used to implement recursion.

A)True

B)False

Q8) Explain how a sequential search works.

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) Applets do not support JMenus.

A)True

B)False

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

Q3) The HTML tag that allows you to display text in the browser's title bar is:

A)< title >

B)< center >

C)< hr >

D)< br >

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

Q5) Write a complete Java applet that displays the phrase "Welcome to my world!" in the center of the applet.

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
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.