Please enable JavaScript to use CodeHS

AP Computer Science A (Mocha)

Lesson 4.3 Using a Class as a Client

Description

In this lesson, students learn about the overarching idea of “using a class as a client”. In Java, everything is represented as a class. Classes are a nice way of bundling up functionality. There are classes written for a lot of common needs (such as the String class and the Character class), and we can use these classes in our programs.

When someone else creates a class, and you use the functionality of that class, that is called being a client of the class. Users don’t need to know exactly how everything works inside the class, they can just use all the functionality of that class without worrying about the inner workings. For example, you can use the String class to create String objects, and call methods on the objects to get information like the length and the characters at certain indices, without ever looking at the source code for the String class.


Objective

Students will be able to:

  • Describe what it means to be a client of a class
  • Explain the benefit of being able to use the functionality of a class without ever having to look at the source code for the class.
  • Read documentation for a class to determine what methods are available to use
  • Create programs that use other classes as a client to solve a specific problem