<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8309195701899484348</id><updated>2011-07-31T02:41:29.621-07:00</updated><title type='text'>Java Programming 2</title><subtitle type='html'>&lt;center&gt;♣ IT - 231♣&lt;/center&gt;</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://achillesocon.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8309195701899484348/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://achillesocon.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Achilles G. Ocon</name><uri>http://www.blogger.com/profile/10895256629237238865</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_JcWR65TJEqY/Srh-VISaSWI/AAAAAAAAAHY/WDFUBOGm9f0/S220/babyNetzko.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8309195701899484348.post-7733544977714189464</id><published>2010-05-14T00:10:00.000-07:00</published><updated>2010-05-14T02:07:22.248-07:00</updated><title type='text'>Java Exceptions</title><content type='html'>&lt;span style="color:#33ff33;"&gt;1.&lt;span style="color:#ffff00;"&gt;Arithmetic Exception&lt;/span&gt; -These Exception occurs, when you divide a number by zero causes an Arithmetic Exception&lt;br /&gt;2.&lt;span style="color:#ffff00;"&gt;Class Cast Exception&lt;/span&gt; -These Exception occurs, when you try to assign a reference variable of a class to an incompatible reference variable of another class&lt;br /&gt;3.&lt;span style="color:#ffff00;"&gt;Array Store Exception&lt;/span&gt; -These Exception occurs, when you assign an array which is not compatible with the data type of that array&lt;br /&gt;4.&lt;span style="color:#ffff00;"&gt;Array Index Out Of Bounds Exception&lt;/span&gt; -These Exception occurs, when you assign an array which is not compatible with the data type of that array&lt;br /&gt;5.&lt;span style="color:#ffff00;"&gt;Null Pointer Exception&lt;/span&gt; -These Exception occurs, when you try to implement an application without referencing the object and allocating to a memory&lt;br /&gt;6.&lt;span style="color:#ffff00;"&gt;Number Format Exception&lt;/span&gt; -These Exception occurs, when you try to convert a string variable in an incorrect format to integer (numeric format) that is not compatible with each other&lt;br /&gt;7.&lt;span style="color:#ffff00;"&gt;ClassNotFoundException&lt;/span&gt; -This Exception occurs when Java run-time system fail to find the specified class mentioned in the program.&lt;br /&gt;8.&lt;span style="color:#ffff00;"&gt;Instantiation Exception&lt;/span&gt; -This Exception occurs when you create an object of an abstract class and interface&lt;br /&gt;9.&lt;span style="color:#ffff00;"&gt;Illegal Access Exception&lt;/span&gt; -This Exception occurs when you create an object of an abstract class and interface&lt;br /&gt;10.&lt;span style="color:#ffff00;"&gt;Not Such Method Exception&lt;/span&gt; -This Exception occurs when the method you call does not exist in class&lt;br /&gt;11.&lt;span style="color:#ffff00;"&gt;Negative ArraySizeException&lt;/span&gt; -These are Exception, when you declare an array of negative size.&lt;br /&gt;12. &lt;span style="color:#ffff00;"&gt;Try-catch-finally block&lt;br /&gt;&lt;/span&gt;Key aspects about the syntax of the try-catch-finally construct:&lt;br /&gt;– The block notation is mandatory.&lt;br /&gt;– For each try block, there can be one or more catch blocks, but only one finally block.&lt;br /&gt;– The catch blocks and finally blocks must always appear in conjunction with the try block, and in the above order.&lt;br /&gt;– A try block must be followed by AT LEAST one catch block OR one finally block, or both.&lt;br /&gt;– Each catch block defines an exception handle. The header of the catch block takes exactly one argument, which is the exception its block is willing to handle. The exception must be of the Throwable class or one of its subclasses.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8309195701899484348-7733544977714189464?l=achillesocon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://achillesocon.blogspot.com/feeds/7733544977714189464/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8309195701899484348&amp;postID=7733544977714189464' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8309195701899484348/posts/default/7733544977714189464'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8309195701899484348/posts/default/7733544977714189464'/><link rel='alternate' type='text/html' href='http://achillesocon.blogspot.com/2010/05/java-exceptions.html' title='Java Exceptions'/><author><name>Achilles G. Ocon</name><uri>http://www.blogger.com/profile/10895256629237238865</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_JcWR65TJEqY/Srh-VISaSWI/AAAAAAAAAHY/WDFUBOGm9f0/S220/babyNetzko.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8309195701899484348.post-4433559517118243943</id><published>2010-04-22T01:52:00.000-07:00</published><updated>2010-04-22T02:26:09.397-07:00</updated><title type='text'>Inheritance, Polymorphism, Interface</title><content type='html'>&lt;div align="center"&gt;&lt;span style="color:#ffff33;"&gt;Inheritance&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;In Java, all classes, including the classes that make up the Java API, are subclassed from the Object superclass.&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#ffff00;"&gt;Supper Class&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;It is any class above a specific class in the class hierarchy.&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#ffff00;"&gt;Subclass&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;Any class below a specific class in the class hierarchy.&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#ffff00;"&gt;Benefits of Inheritance&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;Benefits of Inheritance in OOP : Reusability–Once a behavior (method) is defined in a superclass, that behavior is automatically inherited by all subclasses. –Thus, you can encode a method only once and they can be used by all subclasses. –A subclass only needs to implement the differences between itself and the parent.&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#ffff00;"&gt;Overriding Methods&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;If for some reason a derived class needs to have a different implementation of a certain method from that of the superclass, overriding methods could prove to be very useful. ●A subclass can override a method defined in its superclass by providing a new implementation for that method.&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt;Sample Code&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt;public class Person { &lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt;:&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt;:&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt;public String getName(){&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt; System.out.println("Parent: getName"); &lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt;return name; &lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt;} &lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#ffff00;"&gt;Final Methods and Classes&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;Final Classes–Classes that cannot be extended–To declare final classes, we write,public final ClassName{. . . }&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;Other examples of final classes are wrapper classes and Strings.&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;public final class Person { . . . } &lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;Final Methods–Methods that cannot be overridden–&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;To declare final methods, we write,&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;public final [returnType] [methodName]([parameters]){. . .}&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;Static methods are automatically final.&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt;ExampleCode:&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt;public final String getName(){&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt; return name;&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt; } &lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#ffff00;"&gt;Polimorphism&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;It is the ability of a reference variable to change behavior according to what object it is holding.&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;This allows multiple objects of different subclasses to be treated as objects of a single superclass, while automatically selecting the proper methods to apply to a particular object based on the subclass it belongs to. &lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;In Java, we can create a reference that is of type superclass to an object of its subclass.&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#ffff00;"&gt;ExampleCode:&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#ffff00;"&gt;public static main( String[] args ) { &lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#ffff00;"&gt;Person  ref;&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#ffff00;"&gt; Student studentObject = new Student(); &lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#ffff00;"&gt;Employee employeeObject = new Employee(); &lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#ffff00;"&gt;ref = studentObject; //Person reference points to a      // Student object &lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#ffff00;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#ffff00;"&gt;Abstrac Classes&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt; It is a class that cannot be instantiated. &lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;Often appears at the top of an object-oriented programming class hierarchy, defining the broad types of actions possible with objects of all subclasses of the class.&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#ffff00;"&gt;Abstract Methods&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;Are methods in the abstract classes that do not have implementation–To create an abstract method, just write the method declaration without the body and use the abstract keyword&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#ffff00;"&gt;Interface&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;An interface&lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt;is a special kind of block containing method signatures (and possibly constants) only. &lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt;defines the signatures of a set of methods, without the body. &lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt;defines a standard and public way of specifying the behavior of classes. &lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt;allows classes, regardless of their locations in the class hierarchy, to implement common behaviors. &lt;/span&gt;&lt;/div&gt;&lt;div align="left"&gt;&lt;span style="color:#33ff33;"&gt;NOTE: interfaces exhibit polymorphism as well, since program may call an interface method, and the proper version of that method will be executed depending on the type of object passed to the interface method call. &lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8309195701899484348-4433559517118243943?l=achillesocon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://achillesocon.blogspot.com/feeds/4433559517118243943/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8309195701899484348&amp;postID=4433559517118243943' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8309195701899484348/posts/default/4433559517118243943'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8309195701899484348/posts/default/4433559517118243943'/><link rel='alternate' type='text/html' href='http://achillesocon.blogspot.com/2010/04/inheritance-polymorphism-interface.html' title='Inheritance, Polymorphism, Interface'/><author><name>Achilles G. Ocon</name><uri>http://www.blogger.com/profile/10895256629237238865</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_JcWR65TJEqY/Srh-VISaSWI/AAAAAAAAAHY/WDFUBOGm9f0/S220/babyNetzko.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8309195701899484348.post-3944833921712192555</id><published>2010-04-19T02:38:00.000-07:00</published><updated>2010-04-19T20:39:00.551-07:00</updated><title type='text'>Working with the Java Class</title><content type='html'>&lt;div  style="text-align: center;font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;Object-Oriented Programming&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;Object-oriented programming (OOP) is a programming paradigm that uses "objects" – data structures consisting of datafields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction, encapsulation, modularity, polymorphism, and inheritance. It was not commonly used in mainstream software application development until the early 1990s.[citation needed] Many modern programming languages now support OOP.&lt;br /&gt;Object-oriented programming has roots that can be traced to the 1960s. As hardware and software became increasingly complex, manageability often became a concern. Researchers studied ways to maintain software quality and developed object-oriented programming in part to address common problems by strongly emphasizing discrete, reusable units of programming logic.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;Encapsulation&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;In programming, the process of combining elements to create a new entity. For example, a procedure is a type of encapsulation because it combines a series of computer instructions. Likewise, a complex data type, such as a record or class, relies on encapsulation. Object-oriented programming languages rely heavily on encapsulation to create high-level objects. Encapsulation is closely related to abstraction and information hiding.&lt;/span&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;Classes and Objects&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;Objects&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;In the "real" world, objects are the entities of which the world is comprised.   Everything that happens in the world is related to the interactions between the objects in the world.   Just as atoms, which are objects, combine to form molecules and larger objects, the interacting entities in the world can be thought of as interactions between and among both singular ("atomic") as well as compound ("composed") objects.   The real world consists of many, many objects interacting in many ways.   While each object may not be overly complex, their myriad of interactions creates the overall complexity of the natural world.  It is this complexity that we wish to capture in our software systems.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;Class Variables&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;Also known as &lt;/span&gt;&lt;i style="color: rgb(51, 255, 51);"&gt;static&lt;/i&gt;&lt;span style="color: rgb(51, 255, 51);"&gt; variables, these are any variables (properties) that are associated with a class, and not an object instance. There is always only one copy of a class variable, regardless of the number of object instances that are created from that class. Class variables do not use the prototype object to implement inheritance. You access a class variable directly through the class, and not through an object instance; you must define a class in a constructor function before you can define class variables.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;Classes&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;Many objects differ from each other only in the value of the data that they hold.  For example, both a red crayon and a blue crayon are crayons; they differ only in the value of the color attribute, one has a red color and the other a blue color.   Our object-oriented system needs a way to capture the abstraction of a crayon, independent of the value of its color.   That is, we want to express that a set of objects are abstractly equivalent, differing only in the values of their attributes and perhaps, thus differing in the behaviors that result from those values.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(255, 255, 0);font-size:100%;" &gt;Class Instantiation&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;The  process of creating objects from a class is called instantiation. So an  object is always an instance of a class which represents the blueprint.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;The  object is constructed using the class and must be created before being  used in a program.&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;Objects are manipulated through object references  (also called reference values or simply references.&lt;/span&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;Method Declaration&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;It provides a lot of information about the method to the compiler, the runtime system and to other classes and objects. Besides the name of the method, the method declaration carries  information such as the return type of the method, the number and type of the arguments required by the method, and what other classes and objects can call the method. &lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;Static Methods&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;p style="color: rgb(51, 255, 51);"&gt;&lt;span style="font-size:100%;"&gt;A static method is a &lt;span style="text-decoration: underline;"&gt;&lt;span style="font-style: italic;"&gt;method&lt;/span&gt;&lt;/span&gt; which accepts  arguments instead of using &lt;span style="text-decoration: underline;"&gt;instance varuables&lt;/span&gt;.&lt;/span&gt;&lt;/p&gt; &lt;p style="color: rgb(51, 255, 51);"&gt;&lt;span style="font-size:100%;"&gt;The opposite of a static method is an &lt;span style="text-decoration: underline;"&gt;instance method&lt;/span&gt;.&lt;/span&gt;&lt;/p&gt; &lt;p style="color: rgb(51, 255, 51);"&gt;&lt;span style="font-size:100%;"&gt;The default for a method is to be an instance method. Methods must be  explicitly defined as static methods.&lt;/span&gt;&lt;/p&gt; &lt;p style="color: rgb(51, 255, 51);"&gt;&lt;span style="font-size:100%;"&gt;A static method is also referred to as a class method.&lt;/span&gt;&lt;/p&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 255, 51);"&gt;Parameter Passing&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;Pass-by-Value&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;p  style="color: rgb(51, 255, 51); text-align: center;font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span&gt;When you use pass-by-&lt;em&gt;value&lt;/em&gt;, the compiler copies the value of an argument in a calling function to a  corresponding non-pointer or non-reference parameter in the called function definition.&lt;/span&gt; The parameter in the called function is  initialized with the value of the passed argument. As long as the parameter has not  been declared as constant, the value of the parameter can be changed, but the  changes are only performed within the scope of the called function only; they  have no effect on the value of the argument in the calling function.&lt;/span&gt;&lt;/p&gt;&lt;div  style="text-align: center;font-family:arial;"&gt; &lt;/div&gt;&lt;p  style="color: rgb(51, 255, 51); text-align: center;font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt;In the following example, &lt;span class="xph"&gt;main&lt;/span&gt; passes &lt;span class="xph"&gt;func&lt;/span&gt; two values: &lt;span class="xph"&gt;5&lt;/span&gt; and &lt;span class="xph"&gt;7&lt;/span&gt;. The function &lt;span class="xph"&gt;func&lt;/span&gt; receives  copies of these values and accesses them by the identifiers &lt;span class="xph"&gt;a&lt;/span&gt;  and &lt;span class="xph"&gt;b&lt;/span&gt;. The function &lt;span class="xph"&gt;func&lt;/span&gt;  changes the value of &lt;span class="xph"&gt;a&lt;/span&gt;. When control passes back to &lt;span class="xph"&gt;main&lt;/span&gt;, the actual values of &lt;span class="xph"&gt;x&lt;/span&gt; and &lt;span class="xph"&gt;y&lt;/span&gt; are not changed. &lt;/span&gt;&lt;/p&gt; &lt;pre style="color: rgb(51, 255, 51);" class="xmp"&gt;&lt;span style="font-size:100%;"&gt;/**&lt;br /&gt;** This example illustrates calling a function by value&lt;br /&gt;**/&lt;br /&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;&lt;br /&gt;void func (int a, int b)&lt;br /&gt;{&lt;br /&gt; a += b;&lt;br /&gt; printf("In func, a = %d    b = %d\n", a, b);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main(void)&lt;br /&gt;{&lt;br /&gt; int x = 5, y = 7;&lt;br /&gt; func(x, y);&lt;br /&gt; printf("In main, x = %d    y = %d\n", x, y);&lt;br /&gt; return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/stdio.h&gt;&lt;/span&gt;&lt;/pre&gt;&lt;p  style="color: rgb(51, 255, 51); text-align: left;font-family:arial;" class="indatacontent"&gt;&lt;span style="font-size:100%;"&gt;The output of the program is:&lt;/span&gt;&lt;/p&gt;&lt;div face="arial" style="text-align: center;"&gt;&lt;div style="text-align: left;"&gt; &lt;pre style="color: rgb(51, 255, 51);" class="xmp"&gt;&lt;span style="font-size:100%;"&gt;In func, a = 12 b = 7&lt;br /&gt;In main, x = 5  y = 7&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;Pass-by-Reference&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;p  style="color: rgb(51, 255, 51); text-align: center;font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt;Passing by &lt;em&gt;by reference&lt;/em&gt; refers to a method of passing the address of an argument in the calling function to a corresponding  parameter in the called function.  &lt;img src="http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/topic/com.ibm.xlcpp8l.doc/language/ref/ngclang.gif" alt="C only" /&gt;In C, the corresponding parameter in the called function  must be declared as a pointer type.  &lt;img src="http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/topic/com.ibm.xlcpp8l.doc/language/ref/ngcpp.gif" alt="C++ only" /&gt; In C++, the corresponding parameter can be declared as any reference type, not just a pointer type. &lt;/span&gt;&lt;/p&gt;&lt;div face="arial" style="text-align: center;"&gt; &lt;/div&gt;&lt;p  style="color: rgb(51, 255, 51); text-align: center;font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt;In this way, the value of the argument in the calling function can be  modified by the called function.&lt;/span&gt;&lt;/p&gt;&lt;div style="text-align: center; font-family: arial;"&gt; &lt;/div&gt;&lt;p  style="color: rgb(51, 255, 51); text-align: center;font-family:arial;"&gt;&lt;span style="font-size:100%;"&gt;The following example shows how arguments are passed by reference. In C++, the reference parameters are initialized with the  actual arguments when the function is called. In C, the pointer parameters are  initialized with pointer values when the function is called.&lt;/span&gt;&lt;/p&gt;&lt;div style="text-align: center; font-family: arial;"&gt; &lt;/div&gt;&lt;div  style="color: rgb(51, 255, 51); text-align: left;font-family:arial;" class="qualifstart"&gt;&lt;span style="font-size:100%;"&gt;C++ only&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: arial; text-align: left;"&gt; &lt;pre style="color: rgb(51, 255, 51);" class="xmp"&gt;&lt;span style="font-size:100%;"&gt;#include &lt;stdio.h&gt;&lt;br /&gt;&lt;br /&gt;void swapnum(int &amp;amp;i, int &amp;amp;j) {&lt;br /&gt;int temp = i;&lt;br /&gt;i = j;&lt;br /&gt;j = temp;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main(void) {&lt;br /&gt;int a = 10;&lt;br /&gt;int b = 20;&lt;br /&gt;&lt;br /&gt;swapnum(a, b);&lt;br /&gt;printf("A is %d and B is %d\n", a, b);&lt;br /&gt;return 0;&lt;br /&gt;}&lt;/stdio.h&gt;&lt;/span&gt;&lt;/pre&gt; &lt;/div&gt;&lt;div  style="color: rgb(51, 255, 51); text-align: left;font-family:arial;" class="qualifend"&gt;&lt;span style="font-size:100%;"&gt; End of C++ only&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: arial; text-align: left;"&gt; &lt;/div&gt;&lt;div  style="color: rgb(51, 255, 51); text-align: left;font-family:arial;" class="qualifstart"&gt;&lt;span style="font-size:100%;"&gt;C only&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center; font-family: arial;"&gt;&lt;div style="text-align: left;"&gt; &lt;pre style="color: rgb(51, 255, 51);" class="xmp"&gt;&lt;span style="font-size:100%;"&gt;#include &lt;stdio.h&gt;&lt;br /&gt;&lt;br /&gt;void swapnum(int *i, int *j) {&lt;br /&gt;int temp = i;&lt;br /&gt;i = j;&lt;br /&gt;j = temp;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main(void) {&lt;br /&gt;int a = 10;&lt;br /&gt;int b = 20;&lt;br /&gt;&lt;br /&gt;swapnum(&amp;amp;a, &amp;amp;b);&lt;br /&gt;printf("A is %d and B is %d\n", a, b);&lt;br /&gt;return 0;&lt;br /&gt;}&lt;/stdio.h&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8309195701899484348-3944833921712192555?l=achillesocon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://achillesocon.blogspot.com/feeds/3944833921712192555/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8309195701899484348&amp;postID=3944833921712192555' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8309195701899484348/posts/default/3944833921712192555'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8309195701899484348/posts/default/3944833921712192555'/><link rel='alternate' type='text/html' href='http://achillesocon.blogspot.com/2010/04/working-with-java-class.html' title='Working with the Java Class'/><author><name>Achilles G. Ocon</name><uri>http://www.blogger.com/profile/10895256629237238865</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_JcWR65TJEqY/Srh-VISaSWI/AAAAAAAAAHY/WDFUBOGm9f0/S220/babyNetzko.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8309195701899484348.post-7395562416594053603</id><published>2010-04-14T00:51:00.000-07:00</published><updated>2010-04-14T02:45:20.772-07:00</updated><title type='text'>Introduction to Java Programming</title><content type='html'>&lt;a href="http://2.bp.blogspot.com/_JcWR65TJEqY/S8V7K5jb48I/AAAAAAAAAH8/lSwzWRloyCY/s1600/Phases.gif"&gt;&lt;/a&gt;&lt;div align="center"&gt;&lt;span style="color:#ffff33;"&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;span style="color:#ffff33;"&gt;&lt;strong&gt;History&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;Java is a high-level object-oriented programming language developed by the Sun Microsystems. Though it is associated with the World Wide Web but it is older than the origin of Web. It was only developed keeping in mind the consumer electronics and communication equipments. It came into existence as a part of web application, web services and a platform independent programming language in the 1990s. &lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;Earlier, C++ was widely used to write object oriented programming languages, however, it was not a platform independent and needed to be recompiled for each different CPUs. A team of Sun Microsystems including Patrick Naughton, Mike Sheridan in the guidance of James Goslings decided to develop an advanced programming language for the betterment of consumer electronic devices. They wanted to make it new software based on the power of networks that can run on different application areas, such as computers and electronic devices. In the year 1991 they make platform independent software and named it Oak. But later due to some patent conflicts, it was renamed as Java and in 1995 the Java 1.0 was officially released to the world.&lt;br /&gt;Java is influenced by C, C++, Smalltalk and borrowed some advanced features from some other languages. The company promoted this software product with a slogan named “Write Once Run Anywhere” that means it can develop and run on any device equipped with Java Virtual Machine (JVM). This language is applicable in all kinds of operating systems including Linux, Windows, Solaris, and HP-UX etc. &lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;br /&gt;&lt;span style="color:#ffff33;"&gt;&lt;strong&gt;Java technology&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;Since 1995, Java has changed our world . . . and our expectations..&lt;br /&gt;Today, with technology such a part of our daily lives, we take it for granted that we can be connected and access applications and content anywhere, anytime. Because of Java, we expect digital devices to be smarter, more functional, and way more entertaining.&lt;br /&gt;In the early 90s, extending the power of network computing to the activities of everyday life was a radical vision. In 1991, a small group of Sun engineers called the "Green Team" believed that the next wave in computing was the union of digital consumer devices and computers. Led by James Gosling, the team worked around the clock and created the programming language that would revolutionize our world – Java.&lt;br /&gt;The Green Team demonstrated their new language with an interactive, handheld home-entertainment controller that was originally targeted at the digital cable television industry. Unfortunately, the concept was much too advanced for the them at the time. But it was just right for the Internet, which was just starting to take off. In 1995, the team announced that the Netscape Navigator Internet browser would incorporate Java technology.&lt;br /&gt;Today, Java not only permeates the Internet, but also is the invisible force behind many of the applications and devises that power our day-to-day lives. From mobile phones to handheld devises, games and navigation systems to e-business solutions, Java is everywhere!&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;&lt;span style="color:#ffff33;"&gt;&lt;strong&gt;Java features&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;The &lt;span style="color:#ffff33;"&gt;Java Virtual Machine&lt;/span&gt;●Java Virtual Machine (JVM)–an imaginary machine that is implemented by emulating software on a real machine–provides the hardware platform specifications to which you compile all Java technology code●Bytecode–a special machine language that can be understood by the Java Virtual Machine (JVM)–independent of any particular computer hardware, so any computer with a Java interpreter can execute the compiled Java program.&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;●&lt;span style="color:#ffff33;"&gt;Garbage collection thread &lt;/span&gt;–responsible for freeing any memory that can be freed. This happens automa&lt;/span&gt;&lt;span style="color:#33ff33;"&gt;tically during the lifetime of the Java program.–programmer is freed from the burden of having to deallocate that memory themselves&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;&lt;/span&gt; &lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;●&lt;span style="color:#ffff33;"&gt;Code security&lt;/span&gt; is attained in Java through the implementation of its Java Runtime Environment (JRE). ●JRE –runs code compiled for a JVM and performs class loading (through the class loader), code verification (through the bytecode verifier) and finally code execution&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;●Class Loader–responsible for loading all classes needed for the Java program–adds security by separating the namespaces for the classes of the local file system from those that are imported from network sources–After loading all the classes, the memory layout of the executable is then determined. This adds protection against unauthorized access to restricted areas of the code since the memory layout is determined during runtime&lt;/span&gt;&lt;/div&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;Bytecode verifier–tests the format of the code fragments and checks the code fragments for illegal code that can violate access rights to objects&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#ffff33;"&gt;&lt;strong&gt;Phases of java program&lt;/strong&gt;&lt;/span&gt; &lt;/div&gt;&lt;p align="center"&gt;&lt;span style="color:#33ff33;"&gt;Phase Purpose Tasks&lt;br /&gt;&lt;/span&gt;&lt;span style="color:#33ff33;"&gt;&lt;span style="color:#ffff33;"&gt;1&lt;/span&gt;&lt;br /&gt;Planning&lt;br /&gt;Prepare log sheets&lt;br /&gt;Record estimates for time in each phase&lt;br /&gt;Record planning time in the time recording log&lt;br /&gt;&lt;span style="color:#ffff33;"&gt;2&lt;/span&gt;&lt;br /&gt;Requirements&lt;br /&gt;Study and understand the requirements in detail&lt;br /&gt;Determine the exact formats for input and output, and any command line parameters.&lt;br /&gt;Record requirements time in the time recording log&lt;br /&gt;&lt;span style="color:#ffff33;"&gt;3&lt;br /&gt;&lt;/span&gt;Design&lt;br /&gt;Think about the algorithms you will use&lt;br /&gt;Think about the program design&lt;br /&gt;Record design time in the time recording log&lt;br /&gt;&lt;span style="color:#ffff33;"&gt;4&lt;/span&gt;&lt;br /&gt;Code&lt;br /&gt;Implement the design&lt;br /&gt;type in the code&lt;br /&gt;Record coding time in the time recording log&lt;br /&gt;&lt;span style="color:#ffff33;"&gt;5&lt;/span&gt;&lt;br /&gt;Compile&lt;br /&gt;Compile the program&lt;br /&gt;Fix all defects found&lt;br /&gt;Record compile time in the time recording log&lt;br /&gt;&lt;span style="color:#ffff33;"&gt;6&lt;/span&gt;&lt;br /&gt;Test&lt;br /&gt;Develop test cases&lt;br /&gt;Test the program&lt;br /&gt;Debug defects&lt;br /&gt;Fix all defects found&lt;br /&gt;Record testing time in the time recording log&lt;br /&gt;&lt;span style="color:#ffff33;"&gt;7&lt;br /&gt;&lt;/span&gt;Performance&lt;br /&gt;Count lines of code&lt;br /&gt;Develop performance test cases&lt;br /&gt;Execute and record performance&lt;br /&gt;Record performance time in the time recording log&lt;br /&gt;&lt;span style="color:#ffff33;"&gt;8&lt;/span&gt;&lt;br /&gt;Postmortem&lt;br /&gt;Complete the project plan summary form with actual time spent&lt;br /&gt;Think about the experience, and write a brief report&lt;br /&gt;Record postmortem time in the time recording log &lt;/span&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;br /&gt;&lt;span style="color:#ffff33;"&gt;&lt;strong&gt;Difference between Java Application and Java Applets&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div align="center"&gt;&lt;span style="color:#33ff33;"&gt;In simple terms, an applet runs under the control of a browser, whereas an application runs stand-alone, with the support of a virtual machine. As such, an applet is subjected to more stringent security restrictions in terms of file and network access, whereas an application can have free reign over these resources.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#33ff33;"&gt;&lt;div align="center"&gt;Applets are great for creating dynamic and interactive web applications, but the true power of Java lies in writing full blown applications. With the limitation of disk and network access, it would be difficult to write commercial applications (though through the user of server based file systems, not impossible). However, a Java application has full network and local file system access, and its potential is limited only by the creativity of its developers.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="color:#ffff33;"&gt;&lt;strong&gt;What makes a Java an Object Oriented Programming Language&lt;/strong&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8309195701899484348-7395562416594053603?l=achillesocon.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://achillesocon.blogspot.com/feeds/7395562416594053603/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8309195701899484348&amp;postID=7395562416594053603' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8309195701899484348/posts/default/7395562416594053603'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8309195701899484348/posts/default/7395562416594053603'/><link rel='alternate' type='text/html' href='http://achillesocon.blogspot.com/2010/04/introduction-to-java-programming.html' title='Introduction to Java Programming'/><author><name>Achilles G. Ocon</name><uri>http://www.blogger.com/profile/10895256629237238865</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://1.bp.blogspot.com/_JcWR65TJEqY/Srh-VISaSWI/AAAAAAAAAHY/WDFUBOGm9f0/S220/babyNetzko.jpg'/></author><thr:total>0</thr:total></entry></feed>
