Linggo, Hulyo 24, 2011

Java Food For Thought

Java is a simple, object-oriented, network-savvy, interpreted, robust, secure, architecture neutral, portable, high-performance, multi threaded, dynamic language.

Java formerly known as Oak.

Object Oriented Programming is a programming paradigm using objects.

A programming paradigm is a fundamental style of computer programming.

Object Orientation in programming involves  encapsulation, inheritance, polymorphism, and abstraction, is an important approach in programming and program design.

Abstraction means ignoring irrelevant features, properties, or functions and emphasizing the relevant ones.

Encapsulation means that all data members (fields) of a class are declared private.  Some methods may be private, too.

Data encapsulation is the process of hiding internal data from the outside world, and accessing it only through publicly exposed methods.

Inheritance means a class can extend another class, inheriting all its data members and methods while redefining some of them and/or adding its own.

Inheritance allows classes to inherit commonly used state and behavior from other classes.

Polymorphism ensures that the appropriate method is called for an object of a specific type when the object is disguised as a more general type.

An object is a set of data (state) combined with methods (behavior) for manipulating that data.

An object's state is stored in fields.

An object's behavior is exposed through methods

An object is made from a class.

A class is the blueprint for the object.

Common behavior can be defined in a superclass and inherited into a subclass using the extends keyword.

Interface is an abstract type that is used to specify an interface that classes must implement.

An interface may never contain method definitions.

A collection of methods with no implementation is called an interface.

A package is a namespace that organizes a set of related classes and interfaces.

A namespace that organizes classes and interfaces by functionality is called a package.

Conceptually you can think of packages as being similar to different folders on your computer.

"Application Programming Interface", or "API" for short is an enormous class library (a set of packages) suitable for use in your own applications.

Its packages represent the tasks most commonly associated with general-purpose programming.

Instance Variables (Non-Static Fields) - Technically speaking, objects store their individual states in "non-static fields", that is, fields declared without the static keyword. Non-static fields are also known as instance variables because their values are unique to each instance of a class (to each object, in other words); the currentSpeed of one bicycle is independent from the currentSpeed of another.

Class Variables (Static Fields) - A class variable is any field declared with the static modifier; this tells the compiler that there is

exactly one copy of this variable in existence, regardless of how many times the class has been instantiated. A field defining the number of gears for a particular kind of bicycle could be marked as static since conceptually the same number of gears will apply to all instances. The code static int numGears = 6; would create such a static field. Additionally, the keyword final could be added to indicate that the number of gears will never change.

Local Variables - Similar to how an object stores its state in fields, a method will often store its temporary state in local variables. The syntax for declaring a local variable is similar to declaring a field (for example, int count = 0;). There is no special keyword designating a variable as local; that determination comes entirely from the location in which the variable is declared — which is between the opening and closing braces of a method. As such, local variables are only visible to the methods in which they are declared; they are not accessible from the rest of the class.

Parameters - Recall that the signature for the main method is public static void main(String[] args). Here, the args variable is the parameter to this method. The important thing to remember is that parameters are always classified as "variables" not "fields". This applies to other parameter-accepting constructs as well (such as constructors and exception handlers) that you'll learn about later in the tutorial.

An array is a container object that holds a fixed number of values of a single type.

Statements are roughly equivalent to sentences in natural languages. A statement forms a complete unit of execution.

A block is a group of zero or more statements between balanced braces and can be used anywhere a single statement is allowed.

Walang komento:

Mag-post ng isang Komento