Page 271 - Cs_withBlue_J_C11_Flipbook
P. 271
10.6 JAVA LIBRARY CLASS
Some methods are provided by Java for making coding easy. These in-built methods are available in the library class
which can be imported into the code dynamically at runtime. This library further contains packages.
Packages are a group of similar type of classes, interfaces and sub-packages, which contains some built-in classes
containing methods, that are required during coding. Packages can be categorized into two, namely, built-in packages
and user-defined packages.
There are many built-in packages that are commonly used such as java, lang, awt, javax, swing, net, io, util, sql, etc.
To include a package in a program, the syntax is
import java.<packagename>.<classname>;
For examples:
import java.util.*;
import java.io.*;
The ”lang” package is the default package in Java and when we use it, we do not need to use the ‘import’ command
as it is automatically executed.
Let’s Revisit
♦ Strings refer to the combination of different characters including alphabets, digits, punctuators and/or special symbols.
♦ The Character is a built-in class in Java that provides various methods to manipulate characters.
♦ The StringBuffer class is used to create sufficient space in the memory to store a String.
♦ The StringTokenizer class splits the given string into tokens (sequence of characters except delimiters) or words.
MIND DRILL
Solved Questions
A. Tick ( ) the correct answer:
1. "India" is an example of a ………………… .
a. char b. string
c. Both a and b d. None of these
2. What data type does Character.isLetter(char) return?
a. boolean b. char
c. String d. int
3. What is the starting value of the length() method?
a. 0 b. 1
c. 2 d. 3
4. For a string variable, which method returns the character at the given index?
a. length() b. indexOf()
c. charAt() d. None of these
269
Strings 269

