Docsity

Practice Test 2 - Problem Solving and Programming Concepts II | CIS 121, Exams of Computer Science

Toggle sidebar
bg1
CIS 121 - Problem-solving and Programming Concepts II
Practice Test II
Spring 2004
Part I: Fill-in-the-blank.
1. A String method for comparing Strings which is not case-sensitive is
___________________________.
2. A String method that converts a String to all capital letters is
________________________.
3. A Character method that returns true if the character is a number is
___________________.
4. A class variable is identified by the keyword ____________________.
5. A class which has methods for separating a String into pieces is
________________________________ and is from the
______________________________ package.
6. A String method which compares Strings and returns an int 0 if the strings are equal is
_____________________.
7. When we connect two strings to create a third string it is known as
_________________________________.
8. Each string is an array of _________________________________.
9. A(n) _____________________ is an indication that a problem, for example class not
found, has occurred during a program's execution.
10. The paint method is used to _______________________________ on the screen.
11. In our java programs we handle _____________________________ but not
______________________________.
12. The paint method takes an object of the _______________________ class as a
parameter.
13. Three Graphics methods are: ____________________, ______________________, and
______________________________.
14. Java views files as a stream of __________________________________.
15. The Exception and Error classes inherit from the _______________ class.
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Practice Test 2 - Problem Solving and Programming Concepts II | CIS 121 and more Exams Computer Science in PDF only on Docsity!

CIS 121 - Problem-solving and Programming Concepts II

Practice Test II

Spring 2004

Part I: Fill-in-the-blank.

  1. A String method for comparing Strings which is not case-sensitive is ___________________________.
  2. A String method that converts a String to all capital letters is ________________________.
  3. A Character method that returns true if the character is a number is ___________________.
  4. A class variable is identified by the keyword ____________________.
  5. A class which has methods for separating a String into pieces is ________________________________ and is from the ______________________________ package.
  6. A String method which compares Strings and returns an int 0 if the strings are equal is _____________________.
  7. When we connect two strings to create a third string it is known as _________________________________.
  8. Each string is an array of _________________________________.
  9. A(n) _____________________ is an indication that a problem, for example class not found , has occurred during a program's execution.
  10. The paint method is used to _______________________________ on the screen.
  11. In our java programs we handle _____________________________ but not ______________________________.
  12. The paint method takes an object of the _______________________ class as a parameter.
  13. Three Graphics methods are: ____________________, ______________________, and ______________________________.
  14. Java views files as a stream of __________________________________.
  15. The Exception and Error classes inherit from the _______________ class.
  1. Objects can be read/written from/to files when the ________________________ interface is implemented.
  2. A String in java is viewed as an ________________________ of _____________________________.
  3. Some examples of events are _________________________________ and ____________________________________.
  4. Problems that can occur when we try to open files could cause ___________________________ exceptions.

20. ___________ / ____________ blocks are places to put code that might cause exceptions.

  1. The default layout manager for JFrame is ________________________________________.
  2. We can add _________________ to a container in order to create more complex GUIs with more layout managers.
  3. Interfaces must be ____________________________.
  4. According to the Data Hierarchy, a ___________________________ is a group of related records.
  5. Java supports the _____________________ model of exception handling.
  6. The layout manager with rows and columns is called _______________________________.
  7. Linked lists are created by using self- ________________________ classes.
  8. The two instance variables of a ListNode class are: ______________________ and _______________________________.

Part II. Short answers.

  1. List five java GUI components.
  2. Sketch the data hierarchy.

Name of method What it does What it returnsIts Parameters equals compareTo length charAt

Part III. Programming and Discussion.

  1. Write a method called searchString which uses a for loop to traverse a string to find an instance of a particular letter. The method returns true if the letter is found in the string or false if not found. The string and the character to find are the two parameters of the method.
  2. Write a constructor for a class called MyGUI which: a. creates a container called “c:” b. creates two buttons called “start” and “exit:” c. adds an ActionListener to each of the buttons and adds the buttons to the container:
  3. Write the lines of code to draw a box outlined in red and with the dimensions of width = 100 and height = 200.
  1. Describe how exception handling works. Make sure to include keywords try, catch, finally, and throws. Also explain why we would use it instead of regular error checking code. The number of items in a Vector can be determined using the ____________________________ method. Write a method (header and body) called titleFormat that receives a String as a parameter. The parameter is used to return a new String that capitalizes the first letter of first word and that capitalizes every word with four or more letters in it. For example, if “my puppy named Red” is passed, a new String is created and returned as “My Puppy Named Red”. Write a method (header and body) called socialSecurityFormat that receives a String as a parameter. This parameter is used to return a new String that is in the following format: ###-##-####. For example, if “ss26-45899-65i” is passed, a new String is created and returned as “264-58-9965”. All non-numeric characters are eliminated, the social security number is formatted to have three digits followed by a hyphen, followed by two digits, followed by another hyphen, and then the remaining four digits. If there are more nine digits or less than nine digits in the passed String parameter, then an error message is generated, and the “000-00-0000” String is returned by the method. Write a method called shuffleCards that takes a Vector as an object. The Vector used in this method will contain only Card objects. The method will randomly order each Card in the Vector. Write a method called removeSmallTrees that takes a Vector as an object. The Vector will only contain Tree objects (and subclasses such as OakTree and PineTree). This method removes all