Summary 3
Summary 3
- Object methods are called on the object:
myObject.myMethod(); //correct object method call myMethod(myObject); ////illegal object method call
- Java indexes are zero-based.
- Java strings have a length property which is not zero based; this allows a null string to have a length of 0 (zero).
- The Java escape character is a backslash and is used to instruct the interpreter to interpret the character that follows it literally, or to indicate a special character such as a newline character.
- Classes have a public interface and a hidden implementation.
- Every object that is an instance of a particular class, inherits all the methods and variables of that class.
- The access level
publicin a class definition means that the class can be instantiated by any other class.public class MyClass { } - Class constructors must have the same name as the class, and initialise the instance variables of the object they instantiate.
- Class definitions must include definitions of all instance methods.
- The access level
publicin a method definition means that the method can be called by any other class.//public int myMethod() { } - Method definitions should include an access level and the data type of the return value.
//public int myMethod() { } - All instance variables must be declared in the class definition, but placed outside the constructor and method definitions.
- Classes are instantiated as follows:
ClassName objectName = new objectConstructorName(arguments);
- More than one instance of most classes can exist simultaneously, and method calls to the same methods of each object can be made whenever required.
- The console command
javadoc ClassName.javawill generate documentation for the classClassName, provided the class has been commented correctly. - Comment blocks to be interpreted by
javadocmust begin with\** - The indicator
@parammust precede a comment line that describes a constructor or method parameter. - The indicator
@returnmust precede a comment line that describes what a method returns. - Classes may contain more than one constructor; the constructor arguments will determine which constructor is used for object instantiation.
© G. Hearn, & University of the Western Cape, 2006
Copyright 2007-2008,
by the Contributing Authors.
Cite/attribute Resource.
Summary 3. (2008, July 16). Retrieved May 20, 2013, from UWC Free Courseware Web site: http://free.uwc.ac.za/freecourseware/information-systems/java-platform-introduction/summarys/summary-3.
This work is licensed under a
Creative Commons License : Attribution-ShareAlike 3.0.






