Skip to main content

AP Computer Science A Study Guide Questions - 758 Verified Questions

Page 1


AP Computer Science A Study Guide Questions

Course Introduction

AP Computer Science A is an introductory college-level course that covers the fundamentals of computer science, with a primary focus on programming using the Java language. Students learn about problem-solving techniques, algorithm development, object-oriented programming, data structures, and code analysis. The course emphasizes writing, testing, and debugging programs, as well as understanding the ethical and social implications of computing. By the end of the course, students are prepared to take the AP Computer Science A exam and have a solid foundation for further studies in computer science.

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) Applets were designed to run as stand-alone applications.

A)True

B)False

Answer: False

Q2) How are line comments and block comments used?

Answer: A line comment is included as documentation to the programmer or a programmer that might need to modify the code at some later date.A line comment is signified by //.Anything that follows the // is considered a comment by the compiler until the end of the line is reached. A block comment is included as documentation to users of the class.Users of the class are usually other programmers.A block comment begins with /* and ends with */.A block comment my span many lines.Any text between the beginning /* and the ending */ is part of the block comment.A special block comment can be used with Javadoc,a documentation tool included in Java's SDK,to create documentation for users of the class.

Q3) Write a Java statement to determine the length of a string variable called input.Store the result in an integer variable called strLength. Answer: int strLength = input.length();

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) Valid arguments to the System.out object's println method include:

A)"Anything with double quotes"

B)String variables

C)Variables of type int

D)All of the above

Answer: D

Q2) What does it mean to prompt the user?

Answer: Prompting the user means to display a meaningful message to the user asking for some type of input.An example of prompting the user would be displaying a JOptionPane to ask the user to input their name.

Q3) If there is no loss of efficiency in importing an entire Java package instead of importing only classes you use into your program,why would you not just import the entire package?

Answer: Importing only the classes you need into your program makes your program easier to read as well as aiding in documenting the program.Program readability is very important since humans read computer programs,too.

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) What output will be produced by the following code? public class SelectionStatements

{ public static void main(String[] args)

{ int number = 24; if(number % 2 == 0)

System.out.print("The condition evaluated to true!"); else

System.out.print("The condition evaluated to false!");

}

}

Answer: The condition evaluated to true!

Q2) The OR operator in Java is represented by: A)!

B)&& C)| |

D)None of the above

Answer: C

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) An invocation of a method that returns a value can be used as an expression any place that a value of the Type_Returned can be used.

A)True

B)False

Q2) The modifier private means that an instance variable can be accessed by name outside of the class definition.

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) The Java language supports global variables.

A)True B)False

Q5) Discuss a situation in which it is appropriate to use the this parameter.

Q6) What is the purpose of the new operator?

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) To use a package,the program must contain an import statement that names the package.

A)True

B)False

Q2) Define boxing and unboxing.

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

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

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

A)True

B)False

Q6) A bit may have the value of either a 1 or 0.

A)True

B)False

Q7) Add accessor and mutator methods to the Book class created in question #13.

Q8) Explain in detail how main memory works.

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) A ________ loop is a good way to step through the elements of an array and perform some program action on each indexed variable.

A)while

B)do while

C)for

D)all of the above

Q2) What is the correct expression for accessing the 5<sup>th</sup> element in an array named colors?

A)colors[3]

B)colors[4]

C)colors[5]

D)colors[6]

Q3) A method can not change the values stored in the indexed variables of an array argument.

A)True

B)False

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

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

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

Q7) Initialize the array created in number 11 above to -1.0.

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) Overriding is when a derived class redefines a method from the base class.

A)True

B)False

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

Q3) Private methods of the base class are not available for use by derived classes.

A)True

B)False

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

Q5) What is a "has a" relationship?

Q6) A derived class contains only public instance variables and public methods from the base class.

A)True

B)False

Q7) What does the instanceof operator do?

Q8) Explain the modifiers public,protected and private.

Q9) What is encapsulation?

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

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

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

Page 10

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 is polymorphism and how does it relate to late binding?

Q2) What is an abstract method?

Q3) Override the clone method inherited in the Boots class created in number 12 above.

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

Q5) The clone method return type is:

A)the same as the cloned object

B)Object

C)String

D)none of the above

Q6) Java does not use late binding for methods marked as:

A)final

B)static

C)private

D)all of the above

Q7) What are the advantages of polymorphism?

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

11

Q9) Explain the difference between early and late binding.

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

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) List five common examples of exceptions that occur.

Q3) What is the catch or declare rule?

Q4) When an exception is thrown,the code in the surrounding try block continues executing and then the catch block begins execution.

A)True

B)False

Q5) The two most important things about an exception object are its type and the message that it carries in an instance variable of type String.

A)True

B)False

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

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

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) In Java,when you open a text file you should account for a possible:

A)FileNotFoundException

B)FileFullException

C)FileNotReadyException

D)all of the above

Q2) The output stream connected to the computer screen is:

A)System.exit

B)System.quit

C)System.in

D)System.out

Q3) The scanner class has a series of methods that checks to see if there is any more well-formed input of the appropriate type.These methods are called __________ methods:

A)nextToken

B)hasNext

C)getNext

D)testNext

Q4) The FileNotFoundException is a descendant of the class IOException. A)True

B)False

13

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) The third section of a UML class diagram specifies the:

A)class members

B)class name

C)class methods

D)class modifiers

Q2) Class diagrams must contain all class members.

A)True

B)False

Q3) The arrowheads in an inheritance diagram point:

A)North

B)South

C)East

D)West

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

A)True

B)False

Q5) UML was designed to be used with structured programming methodology.

A)True

B)False

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

Page 14

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) The method that must be implemented in a class using the Comparable interface is:

A)public Object compareTo(Object other)

B)public Boolean compareTo(Object other)

C)public int compareTo(Object other)

D)none of the above

Q2) An interface can contain defined constants as well as method headings or instead of method headings.

A)True

B)False

Q3) A class that implements an interface but only gives definitions for some of the method headings given in the interface is called a/an:

A)concrete class

B)abstract class

C)discrete class

D)friendly class

Q4) Inner and outer classes do not have access to each other's private members.

A)True

B)False

Q5) What are two advantages to using inner classes?

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) The remove(Object theElement)method of the ArrayList class returns:

A)Int

B)Double

C)Byte

D)Boolean

Q2) The keyword ___________ can be used to place a bound on a type parameter.

A)Implements

B)Inherits

C)Encapsulates

D)Extends

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

A)generics

B)ArrayList

C)Base type

D)None of the above

Q4) A for loop is an enhanced loop.

A)True

B)False

Q5) What is a parameterized class?

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

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) If you define a clone method,the class should implement the Cloneable interface.

A)True

B)False

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

A)True

B)False

Q3) If the head instance variable of a linked list contains a reference to null,this means the list is:

A)full

B)empty

C)lost

D)none of the above

Q4) The first node in a linked list is commonly referred to as the ________ node.

A)head

B)tail

C)predecessor

D)successor

Q5) What is the result of a postorder 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.

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) What is the purpose of the Java Iterator interface?

Q2) All of the following are methods of the Iterator interface except:

A)clear()

B)hasNext()

C)next()

D)remove()

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) If you do not need efficient random access but need to efficiently move sequentially through the list,then use the _____________ class.

A)Vector< T >

B)LinkedList< T >

C)HashSet< T >

D)TreeSet< T >

Q5) Classes that implement the Set interface allows duplicate elements to occur.

A)True

B)False

18

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

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 _____________ manager is the simplest layout manager.It arranges components one after the other,going from left to right,in the order in which you add them.

A)BorderLayout

B)FlowLayout

C)GridLayout

D)AbsoluteLayout

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

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

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

A)True

B)False

Q5) Write Java statements to add menu items named "Circle","Square",and "Rectangle" to the menu created in number 7 above.

Page 19

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) A view port shows only part of the text at one time.

A)True

B)False

Q2) The Java Color class mixes amounts of red,green and yellow to produce any new color you might want.

A)True

B)False

Q3) All of the following are methods of the Graphics class except:

A)drawRect

B)fillRect

C)coloredRect

D)fill3DRect

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

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

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

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

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) ____________ 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) What is a JavaBean?

Q3) The Java language does not support multithreading.

A)True

B)False

Q4) Threads execute in a ___________ fashion.

A)parallel

B)serial

C)complex

D)none of the above

Q5) An InterruptedException is a checked exception.

A)True

B)False

Q6) What are Enterprise JavaBeans?

Q7) Discuss the components of the JavaBean model.

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

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) A recursively written method will usually run slower and use more storage than an equivalent iterative version.

A)True

B)False

Q2) Write a recursive method to print a string backwards.

Q3) A recursive method is one that:

A)Returns a value

B)Initializes a set of variables

C)Returns no value

D)Invokes itself

Q4) The stack is a ________________ data structure.

A)first in - first out

B)last in - last out

C)last in - first out

D)none of the above

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

22

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

A)< h1 >

B)< href >

C)< hr >

D)< br >

Q2) HTML is a high-level language.

A)True

B)False

Q3) Applets normally do not contain a main method.

A)True

B)False

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

A)ImageIcon

B)JAppletIcon

C)IconImage

D)IconJApplet

Q5) HTML is part of the Java language.

A)True

B)False

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

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