Docsity

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

Toggle sidebar
bg1
CIS 121 Practice Test 1
(Chapters 8 - 11)
Name:__________________________________
Part 1: Fill in the blank (1 point each) with the best word to complete the thought.
1) The process of connecting one string to the end of another string is called
_______________________.
2) In object-oriented programming, a(n) ________________ relationship indicates that a class
object contains a reference to an object of another class. Whereas, in a(n)
___________________ relationship, an object of a subclass type may also be treated as an
object of the superclass type.
3) Three methods of the StringTokenizer class involving tokens are _______________________,
_______________________, and _______________________.
4) The method used to initialize an object at its creation is called a(n) _____________________.
5) AWT stands for ______________________________________________.
6) A class for which programmers never intend to instantiate objects is a(n)
_______________________ class.
7) The wrapper class for char is _______________________.
8) The _______________________ class has capacity, insert, delete, and length methods.
9) Each _______________________ in a window has a RGB value which displays the intensity
of the _______________________, _______________________, and
_______________________ color elements.
10) The Container class and the JComponent class are both subclasses the
______________________ class.
11) Mouse clicks, button presses, and radio button selection are examples of user generated
_______________________ that a program listens for.
12) When we implement the interface ActionListener we are required to
_______________________ a method called _______________________________.
13) Every class inherits a _______________________ method from the Object class.
1
pf3
pf4
pf5

Partial preview of the text

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

CIS 121 Practice Test 1 (Chapters 8 - 11) Name:__________________________________ Part 1 : Fill in the blank (1 point each) with the best word to complete the thought.

  1. The process of connecting one string to the end of another string is called _______________________.
  2. In object-oriented programming, a(n) ________________ relationship indicates that a class object contains a reference to an object of another class. Whereas, in a(n) ___________________ relationship, an object of a subclass type may also be treated as an object of the superclass type.
  3. Three methods of the StringTokenizer class involving tokens are _______________________, _______________________, and _______________________.
  4. The method used to initialize an object at its creation is called a(n) _____________________.
  5. AWT stands for ______________________________________________.
  6. A class for which programmers never intend to instantiate objects is a(n) _______________________ class.
  7. The wrapper class for char is _______________________.
  8. The _______________________ class has capacity, insert, delete, and length methods.
  9. Each _______________________ in a window has a RGB value which displays the intensity of the _______________________, _______________________, and _______________________ color elements.
  10. The Container class and the JComponent class are both subclasses the ______________________ class.
  11. Mouse clicks, button presses, and radio button selection are examples of user generated _______________________ that a program listens for.
  12. When we implement the interface ActionListener we are required to _______________________ a method called _______________________________.
  13. Every class inherits a _______________________ method from the Object class.

Part 2 : Discussion

  1. Briefly describe good practices in writing a class definition.
  2. Describe how you would enable a program to respond a purchase button click. What would you have to set up?
  3. Why would you make a class abstract?
  4. Distinguish between static class variables and instance variables.

Part 3 : Programming Note: In the programming section of the real test, you should know how to set up a class definition, write main and instance methods, construct a class diagram, draw using the Graphics object, use the basic JOptionPane dialog boxes, and how to add JLabels, JTextFields, and JButtons to a JFrame object.

  1. Fill in the class diagram below for a basic Time class (you might refer to page 342 to check your work).
  2. For a driver class, write a method that prompts the user for the current time and creates a Time object to store that time.
  1. Given the following data diagrams: Define a constructor for Employee and Date. Define any of the instance methods listed.
  2. Study the Classes Point, Circle and Cylinder in Chapter 9. Be prepared to implement the inheritance relationship via the definition of constructors and/or methods for derived classes just as you did above in #5 to implement the composition relationship among classes. Employee String firstName; String lastName; Date hireDate; getFirstName() getLastName() getHireMonth() getHireDay() getHireYear() toString() Date int month int day int year getMonth() getDay() getYear() toString()

Be prepared to demonstrate the ability to use the methods of the Character, String, StringBuffer and StringTokenizer classes, especially String methods: length charAt equals equalsIgnoreCase compareTo indexOf concat valueOf StringBuffer Methods length capacity setLength ensureCapacity charAt setCharAt reverse append insert delete Character isDigit isLetterOrDigit toUpperCase toLowerCase isUpperCase isLowerCase StringTokenizer nextToken countTokens moreToken Assume g is an object of the Graphics class. Write the statement(s) to do the following: a. Assign the color blue to g. b. Draw a rectangle at the top right corner of the window that is 50 pixels wide and 100 pixels high. c. Using g, write the String “CIS 121 Test 1” in Dialog font, in bold, italic style. d. Output the size of the font currently assigned to g. e. Output the size of the font currently assigned to g.