25-08-2017, 09:32 PM
JAVA Software Development Paradigm Advance OO Programming
JAVA 2.pptx (Size: 600.17 KB / Downloads: 31)
Libraries
Java programs are usually not written from scratch.
There are hundreds of library classes for all occasions.
Library classes are organized into packages. For example:
Constructors
Short procedures for creating objects of a class
Always have the same name as the class
Initialize the object’s fields
May take parameters
A class may have several constructors that differ in the number and/or types of their parameters
Encapsulation and Information Hiding
A class interacts with other classes only through constructors and public methods
Other classes do not need to know the mechanics (implementation details) of a class to use it effectively
Encapsulation facilitates team work and program maintenance (making changes to the code)
Reserved Words
In Java a number of words are reserved for a special purpose.
Reserved words use only lowercase letters.
Reserved words include:
primitive data types: int, double, char, boolean, etc.
storage modifiers: public, private, static, final, etc.
control statements: if, else, switch, while, for, etc.
built-in constants: true, false, null
There are about 50 reserved words total.
Local Variables
Local variables are declared inside a constructor or a method.
Local variables lose their values and are destroyed once the constructor or the method is exited.
The scope of a local variable is from its declaration down to the closing brace of the block in which it is declared.