Strings - Learning Objectives & Essential Knowledge
LEARNING OBJECTIVE		
Explain the relationship between a class and an object.		
Identify, using its signature, the correct constructor being called.		
For String class:
a. Create String objects.
b. Call String methods.		
Compare object references using boolean expressions in program code.		
For algorithms in the context of a particular specification
that involves String objects:
•	Identify standard algorithms.
•	Modify standard algorithms.
•	Develop an algorithm.		

ESSENTIAL KNOWLEDGE		
Data types can be categorized as either primitive or reference.		
A class is the formal implementation, or blueprint, of the attributes and behaviors of an object.		
A class contains a constructor that is invoked to create objects. 		
Constructors are used to set the initial state of an object.		
An object is a specific instance of a class with defined attributes.		
An object’s behavior refers to what the object can do (or what can be done to it) and is defined by methods.		
Every object is created using the keyword new followed by a call to a class’s constructor.		
A parameter is a value that is passed into a constructor. These are often referred to as actual parameters.		
Constructors have the same name as the class.		
When no constructor is written, Java provides a no-argument constructor, and the instance variables are set to default values.		
The parameter list, in the header of a constructor, lists the types of the values that are passed and their variable names. These are often referred to as formal parameters.		
The memory associated with a variable of a reference type holds an object reference value which is the memory address of the referenced object.		
Non-static methods are called through objects of the class.		
The dot operator is used along with the object name to call non-static methods.		
The keyword null is a special value used to indicate that a reference is not associated with any object.		
Constructors should include initial values for all instance variables.		
The actual parameters passed to a constructor must be compatible with the types identified in the formal parameter list.		
A signature consists of the constructor name and the parameter list. 		
A method signature for a method with parameters consists of the method name and the ordered list of parameter types.		
A method signature for a method without parameters consists of the method name and an empty parameter list.		
Methods are said to be overloaded when there are multiple methods with the same name but a different signature.		
Constructors are said to be overloaded when there are multiple constructors with the same name but a different signature.		
A class contains constructors that are invoked to create objects. 		
Values provided in the parameter list need to correspond to the order and type in the method signature.		
Application program interfaces (APIs) and libraries simplify complex programming tasks.		
Existing classes and class libraries can be utilized as appropriate to create objects.		
Documentation for APIs and libraries are essential to understanding the attributes and behaviors of an object of a class.		
Classes in the APIs and libraries are grouped into packages.		
The String class is part of the java.lang package. Classes in the java.lang package are available by default.		
A String literal is enclosed in double quotes.		
String objects can be created by using String literals or by calling the String class constructor.		
String objects are immutable, meaning that String methods do not change the String object.		
Two object references are considered aliases when they both reference the same object.		
Object reference values can be compared, using == and !=, to identify aliases.		
A class hierarchy can be developed by putting common attributes and behaviors of related classes into a single class called a superclass.		
Classes that extend a superclass, called subclasses, can draw upon the existing attributes and behaviors of the superclass without repeating these in the code.		
Extending a subclass from a superclass creates an “is-a” relationship from the subclass to the superclass.		
When a class S “is-a” class T, T is referred to as a superclass, and S is referred to as a subclass.		
The keyword extends is used to establish an inheritance relationship between a subclass and a superclass. A class can extend only one superclass.		
The keyword public affects the access of classes, data, constructors, and methods.		
A void method does not return a value. Its header contains the keyword void before the method name.		
Method overriding occurs when a public method in a subclass has the same method signature as a public method in the superclass.		
A subclass is usually designed to have modified (overridden) or additional methods.		
The Object class is the superclass of all other classes in Java.		
Utilize the Object class through inheritance. 		
Often classes have their own equals method, which can be used to determine whether two objects of the class are equivalent.		
Using a null reference to call a method or access an instance variable causes a NullPointerException to be thrown.		

A reference value can be compared with null, using == or !=, to determine if the reference actually references an object.		
Primitive values can be concatenated with a String object. This causes implicit conversion of the values to String objects.		
String objects can be concatenated using the + or += operator, resulting in a new String object.		
Autoboxing is the automatic conversion that the Java compiler makes between primitive types and their corresponding object wrapper classes. This includes converting an int to an Integer and a double to a Double.		
The Integer class and Double class are part of the java.lang package.		
The Java compiler applies autoboxing when a primitive value is:
•	Assigned to a variable of the corresponding wrapper class.		
Unboxing is the automatic conversion that the Java compiler makes from the wrapper class to the primitive type. This includes converting an Integer to an int and a Double to a double.		
Subclasses of Object often override the toString method with class specific implementations.		
If System.out.print or System.out.println is passed an object, that object’s toString method is called, and the returned String is printed.		
A String object can be concatenated with an object reference, which implicitly calls the referenced object’s toString method.		
The Java compiler applies unboxing when a wrapper class object is:
•	Assigned to a variable of the corresponding primitive type.		
A String object has index values from 0 to length – 1. Attempting to access indices outside this range will result in an IndexOutOfBoundsException.		
There are standard algorithms that utilize String traversals to:
•	Find if one or more substrings has a particular property
•	Determine the number of substrings that meet specific criteria
•	Create a new string with the characters reversed		

Class Constructors and Methods	Explanation		
String Class	
String(String str)	Constructs a new String object that represents the same sequence of characters as str		
int length()	Returns the number of characters in a String object		
String substring(int from, int to)	Returns the substring beginning at index from and ending at index to - 1		
String substring(int from)	Returns substring(from, length())		
int indexOf(String str)
	Returns the index of the first occurrence of str; - 1 if not found		
boolean equals(String other)	Returns true if this is equal to other; returns false otherwise		
int compareTo(String other)	Returns a value <0 if this is less than other; returns zero if this is equal to other; returns a value >0 if this is greater than other		
Integer Class	
Integer(int value)	Constructs a new Integer object that represents the specified int value		
int intValue()	Returns the value of this Integer as an int		
Double Class	
Double(double value)	Constructs a new Double object that represents the specified double value		
double doubleValue()	Returns the value of this Double as a double		
Object Class	
boolean equals(String other)		
String toString()