<?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:blogger='http://schemas.google.com/blogger/2008' 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-1646707475859735103</id><updated>2024-09-14T22:54:08.109-07:00</updated><category term="JAVA"/><category term="OOD"/><title type='text'>The Software Technology Site</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://techcrafty.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646707475859735103/posts/default'/><link rel='alternate' type='text/html' href='http://techcrafty.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ashok Bhagria</name><uri>http://www.blogger.com/profile/10408751745640687906</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1646707475859735103.post-3999911179002701554</id><published>2011-03-25T14:54:00.001-07:00</published><updated>2011-03-25T14:57:16.484-07:00</updated><title type='text'>The Bulls are coming</title><content type='html'>&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZjQbC6zSbEg-96YGjZmCUStZXpU8lGwJwz4znxcq_5AAl8pGu99pzl8XvxsPd4DeFoacOFIoGeFUzjubp4b56w5edRzN07Ung84l0QgMuyvxO2Y6FBRBgIH_VqlITyFb5EmJ-Jgq0udU/s1600/1-wall-street-bull.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;285&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZjQbC6zSbEg-96YGjZmCUStZXpU8lGwJwz4znxcq_5AAl8pGu99pzl8XvxsPd4DeFoacOFIoGeFUzjubp4b56w5edRzN07Ung84l0QgMuyvxO2Y6FBRBgIH_VqlITyFb5EmJ-Jgq0udU/s400/1-wall-street-bull.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techcrafty.blogspot.com/feeds/3999911179002701554/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techcrafty.blogspot.com/2011/03/bulls-are-coming.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1646707475859735103/posts/default/3999911179002701554'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646707475859735103/posts/default/3999911179002701554'/><link rel='alternate' type='text/html' href='http://techcrafty.blogspot.com/2011/03/bulls-are-coming.html' title='The Bulls are coming'/><author><name>Ashok Bhagria</name><uri>http://www.blogger.com/profile/10408751745640687906</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZjQbC6zSbEg-96YGjZmCUStZXpU8lGwJwz4znxcq_5AAl8pGu99pzl8XvxsPd4DeFoacOFIoGeFUzjubp4b56w5edRzN07Ung84l0QgMuyvxO2Y6FBRBgIH_VqlITyFb5EmJ-Jgq0udU/s72-c/1-wall-street-bull.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1646707475859735103.post-1722497854466471793</id><published>2011-03-18T15:07:00.000-07:00</published><updated>2011-03-18T15:15:10.095-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA"/><title type='text'>Java Trivia - Take 1</title><content type='html'>True or false?&lt;br /&gt;
It is preferable to write&lt;br /&gt;
&lt;b&gt;List dogs = new ArrayList();&lt;/b&gt;&lt;br /&gt;
instead of&lt;br /&gt;
&lt;b&gt;List&amp;lt;Dog&amp;gt; dogs = new ArrayList&amp;lt;Dog&amp;gt;();&lt;/b&gt;&lt;br /&gt;
because raw types enable developers to avoid needless verbiage.&lt;br /&gt;
&lt;br /&gt;
Answer: False.&lt;br /&gt;
While  this may seem like needless verbiage, it&#39;s not, as Joshua Bloch argues:  &quot;By telling the compiler what kind of elements the list contains, you  enable it to find many errors at compile time that would otherwise cause  a ClassCastException at runtime. You also eliminate ugly casts from  your program.&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://a7.sphotos.ak.fbcdn.net/hphotos-ak-snc6/166487_1685553990082_1574629154_1522818_6319436_n.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;228&quot; src=&quot;http://a7.sphotos.ak.fbcdn.net/hphotos-ak-snc6/166487_1685553990082_1574629154_1522818_6319436_n.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techcrafty.blogspot.com/feeds/1722497854466471793/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techcrafty.blogspot.com/2011/03/java-trivia-take-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1646707475859735103/posts/default/1722497854466471793'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646707475859735103/posts/default/1722497854466471793'/><link rel='alternate' type='text/html' href='http://techcrafty.blogspot.com/2011/03/java-trivia-take-1.html' title='Java Trivia - Take 1'/><author><name>Ashok Bhagria</name><uri>http://www.blogger.com/profile/10408751745640687906</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1646707475859735103.post-3684322604261087124</id><published>2011-03-18T15:04:00.001-07:00</published><updated>2011-03-18T15:04:52.108-07:00</updated><title type='text'>What is the difference between a Vector and ArrayList?</title><content type='html'>Vectors are synchronized. Any method that touches the Vector&#39;s contents is thread safe&lt;br /&gt;
ArrayList, on the other hand, is unsynchronized, making them, therefore, not thread safe.</content><link rel='replies' type='application/atom+xml' href='http://techcrafty.blogspot.com/feeds/3684322604261087124/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techcrafty.blogspot.com/2011/03/what-is-difference-between-vector-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1646707475859735103/posts/default/3684322604261087124'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646707475859735103/posts/default/3684322604261087124'/><link rel='alternate' type='text/html' href='http://techcrafty.blogspot.com/2011/03/what-is-difference-between-vector-and.html' title='What is the difference between a Vector and ArrayList?'/><author><name>Ashok Bhagria</name><uri>http://www.blogger.com/profile/10408751745640687906</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1646707475859735103.post-1406280803449433920</id><published>2011-03-18T15:03:00.001-07:00</published><updated>2011-03-19T09:06:13.228-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA"/><category scheme="http://www.blogger.com/atom/ns#" term="OOD"/><title type='text'>What is a static member in Java? - OOD 101</title><content type='html'>The keyword &#39;static&#39; preceding a variable(field) or a method makes its static.&lt;br /&gt;
&lt;br /&gt;
static  means, one per class and not one for each instance of the class (or  object). This means that you can use  them                                       without creating an instance  of a class.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Static variables (class variables) VS Instance variables:&lt;/b&gt;&lt;br /&gt;
When a number of objects are created from a class, each object gets gets its own copy of the instance variables.&lt;br /&gt;
Static  variables are however associated with the class, rather than with any  object of the class. Every instance of the class shares the same class  variable, which is in one fixed location in memory. The class variable  can be accessed without creating an instance of the class and any object  can change the value of a class variable.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Static&amp;nbsp; methods (class methods) VS Instance methods:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Instance methods&lt;/b&gt; are associated with an object and      use the instance variables of that object.&lt;br /&gt;
&lt;b&gt;Static methods&lt;/b&gt;  use no instance variables of any     object of the class they are  defined in. A Static method can only access static variables and cannot  access the instance variables. Static methods typically take all they  data from     parameters and compute something from those parameters,      with no reference to variables.  This is typical of     methods which  do some kind of generic calculation.  A good example     of this are the  many utility methods in the predefined Math     class.</content><link rel='replies' type='application/atom+xml' href='http://techcrafty.blogspot.com/feeds/1406280803449433920/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techcrafty.blogspot.com/2011/03/what-is-static-member-in-java-ood-101.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1646707475859735103/posts/default/1406280803449433920'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646707475859735103/posts/default/1406280803449433920'/><link rel='alternate' type='text/html' href='http://techcrafty.blogspot.com/2011/03/what-is-static-member-in-java-ood-101.html' title='What is a static member in Java? - OOD 101'/><author><name>Ashok Bhagria</name><uri>http://www.blogger.com/profile/10408751745640687906</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1646707475859735103.post-6150272785797781652</id><published>2011-03-18T15:01:00.000-07:00</published><updated>2011-03-18T15:15:56.755-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA"/><title type='text'>How do you create a thread in java﻿?</title><content type='html'>(1) Extend the thread class and and override the run() method within the subclass to to define the code executed by the thread.&lt;br /&gt;
&lt;br /&gt;
(2) Implement the Runnable interface and define the run() method.&lt;br /&gt;
&lt;br /&gt;
Implement the Runnable Interface and then instantiate an object of the class.&lt;br /&gt;
&lt;br /&gt;
We need to override the run() method into our class which is the only method that needs to be implemented.&lt;br /&gt;
&lt;br /&gt;
The run() method contains the logic of the thread.&lt;br /&gt;
&lt;br /&gt;
When creating threads, there are two reasons why implementing the Runnable interface may be preferable to extending the Thread class:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Extending the Thread class means that the subclass cannot extend any other class, whereas a class implementing the Runnable interface has this option.&lt;/li&gt;
&lt;li&gt;A class might only be interested in being runnable, and therefore, inheriting the full overhead of the Thread class would be excessive. Further the class can implement multiple interfaces, in addition to Runnable.&lt;/li&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://techcrafty.blogspot.com/feeds/6150272785797781652/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techcrafty.blogspot.com/2011/03/how-do-you-create-thread-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1646707475859735103/posts/default/6150272785797781652'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646707475859735103/posts/default/6150272785797781652'/><link rel='alternate' type='text/html' href='http://techcrafty.blogspot.com/2011/03/how-do-you-create-thread-in-java.html' title='How do you create a thread in java﻿?'/><author><name>Ashok Bhagria</name><uri>http://www.blogger.com/profile/10408751745640687906</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1646707475859735103.post-4507002440398035675</id><published>2011-03-18T14:07:00.001-07:00</published><updated>2011-03-18T15:16:44.095-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA"/><category scheme="http://www.blogger.com/atom/ns#" term="OOD"/><title type='text'>What is the difference between an Interface and an Abstract Class?</title><content type='html'>Interface:&lt;br /&gt;
An interface is a collection of method prototypes, i.e. method signatures only, no body.&lt;br /&gt;
The class that implements the interface must provide an implementation to the methods in the interface.&lt;br /&gt;
So a interface is used to enforce a contract.&lt;br /&gt;
&lt;br /&gt;
Abstract class:&lt;br /&gt;
An abstract class is one that has one or more abstract methods. An abstract method is one that has only a signature and no implementation. An abstract class can have implemented methods. An abstract class cannot be instantiated, but can be sub-classed/extended. The class that extends the abstract class must provide a definition for the abstract methods.&lt;br /&gt;
&lt;br /&gt;
So, an abstract class is used to provide an initial implementation, that needs to be extended by a sub class. It is used to propagate &#39;a kind of&#39; relationship.</content><link rel='replies' type='application/atom+xml' href='http://techcrafty.blogspot.com/feeds/4507002440398035675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techcrafty.blogspot.com/2011/03/what-is-difference-between-interface.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1646707475859735103/posts/default/4507002440398035675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646707475859735103/posts/default/4507002440398035675'/><link rel='alternate' type='text/html' href='http://techcrafty.blogspot.com/2011/03/what-is-difference-between-interface.html' title='What is the difference between an Interface and an Abstract Class?'/><author><name>Ashok Bhagria</name><uri>http://www.blogger.com/profile/10408751745640687906</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1646707475859735103.post-3975841259314623515</id><published>2011-03-18T14:04:00.000-07:00</published><updated>2011-03-18T15:16:15.512-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="OOD"/><title type='text'>What are the three pillars of OOD?</title><content type='html'>(1) Encapsulation:&lt;br /&gt;
The ability to combine attributes (data) and functionality (methods) into a single entity (class).&lt;br /&gt;
&lt;br /&gt;
(2) Inheritance:&lt;br /&gt;
The ability to extend (subclass) a base class, i.e. the capability of a class to use the properties and methods of another class while adding its own functionality.&lt;br /&gt;
&lt;br /&gt;
(3) Polymorphism:&lt;br /&gt;
From the biological term &#39;many forms&#39;&lt;br /&gt;
&lt;br /&gt;
The capability of an action or method to do different things based on the object that it is acting upon.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
(i) Overloaded methods - methods with the same name but different signatures i.e. either a different number or type of parameters or a different return type.&lt;br /&gt;
&lt;br /&gt;
(ii) Overridden methods -  methods that exist in a base class and then redefined within an inherited or subclass. They have the same signature and the subclass definition is used i.e. the subclass definition overrides the definition in the base class.</content><link rel='replies' type='application/atom+xml' href='http://techcrafty.blogspot.com/feeds/3975841259314623515/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://techcrafty.blogspot.com/2011/03/what-are-three-pillars-of-ood.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1646707475859735103/posts/default/3975841259314623515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1646707475859735103/posts/default/3975841259314623515'/><link rel='alternate' type='text/html' href='http://techcrafty.blogspot.com/2011/03/what-are-three-pillars-of-ood.html' title='What are the three pillars of OOD?'/><author><name>Ashok Bhagria</name><uri>http://www.blogger.com/profile/10408751745640687906</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>