Pages

Monday, June 17, 2013

Static Binding VS Dynamic Binding



   Hope you are familiar with the Fish tank example by now.If I brief it a little we created a Fish class which is the parent class or the super class of several other sub classes namely,TankCleaner class,GoldFish class. and we demonstrated our fish tank using the FishDemo class.Thanks to the concept inheritance in OOP, we can extend the super class and inherit its methods and attributes to its sub classes.

So in this way, we can create an object like this.
             ex [1]-----> Fish f1=new Fish();

here, our object name is f1, and it's type of a typical GoldFish.and its reference type also GoldFish.
             ex[2]-------> Fish f2=new GoldFish();
here our object name is f2 and its object type(instance type) is GoldFish, while it references Fish.

           Using the concept overriding, it is possible to insert the  methods available in Fish
class, to its subclasses. Overriding helps us to increase the usability by implementing the same method in different ways. when overriding we have to have the same method signature. [method name and input parameters.return types are not included into method signature.]
  Think about a method available in Fish class called,swim().
               public void swim(){
                           System.out.print("Fish is swimming");
                              }

     And think that there is an overrided method in GoldFish class like this.

              public void swim(){
                           System.out.println("GoldFish is swimming");
                            }

lets move on to our todas topic. if a "f1" object is created as ex[1], and we call the swim method for it like this what will happen??
                           f1.swim();
obviously it will return            Fish is swimming

But think about     f2.swim();  
                   You will se that it will return         GoldFish is swimming


Lets digg into the theory behind this. when running  the second example, at the compile time, the compiler has to think about 2 options whether  to implement the super class's implementation or the sub class's implementation.Actually the the compiler does not decide anything  and it leaves it to be decided at the run time.Since the object is considered as as a real world object, it should be implemented in the real world way.this is decided at the run time. This binding is called , Dynamic binding.

Dynamic binding happens only for methods which are inherited from super classes and overridden in the sub classes.Such method calls are bound, based on their actual object type.

Static binding
If the compiler can resolve the binding at the compile time only then such a binding is called Static Binding or Early Binding.All the static method calls are resolved at compile time itself and hence we have static binding for static method calls.
        Similarly, access to all the member variables in Java follows static binding as Java doesn't support (in fact, it discourages) polymorphic behavior of member variables.
So it is worth to have a clear understanding, that variables are bound at the compilation time.

                                                                         Achini
                                                             



Don't forget to become a follower of SeethaGangula.!!!

Sunday, April 21, 2013

How to install Apache Ant in windows 7



Apache Ant is used for creating build files. Let's see how to install apache ant to your computer successfully.
First you need to download the zip file from this url.

Make sure you extract the file into a folder called APACHE_ANT. inside that there should be bin, manual, etc, lib like folders. Then you have to copy the path to the APACHE_ANT. In my case it is this.

E:\program filez\ANT-HOME


Then go to System Properties window and and click on environmental variables. Computer->(on the upper corner of my computer window ) System Properties
There you will find this window.

Edit the 1st appearing table containing user variables. 


Type the variable name as ANT_HOME. and add the copied path as the value. You should have already added java home variable. If not click on New tab and add JAVA_HOME variable as well. it's value should be the path to your JDK. 
Then in the system variables table find the Path variable. You have to add some additional thing to the existing one. so just type a semicolon (;) at the end of the current path.  The go to the ANT_HOME folder you created and go to the bin folder inside it. copy the path and paste it after the semicolon. hit ok and now you are done !!!.
To check whether you have installed it correctly type "cmd" at the search area of start button and get the command prompt. then just type ant and hit enter. If you get a msg like this you have installed ant correctly.





Don't forget to become a follower of SeethaGangula.!!!

Monday, February 11, 2013

Chain of Responsibility Design Pattern in Java



Don't forget to become a follower of SeethaGangula.!!!

Artificial Intelligence- another computing paradigm




The aim of artificial intelligence is, in some way try to make computers perform tasks that humans tend to be good at. It fills the gap between scientists who study about human behavior and computer scientists. A computer will always obey exactly for a given set of rules written in a programming language. So human scientists can test their theories about human behaviour by converting them into computer programs. For computer scientists, modeling human behaviour in a computer program is still a big challenge.

So Why AI?

Human beings have been outperformed by computers in many tasks. We can see this specially in these areas.

01. Numerical Computations

computers are obviously more faster and accurate than humans when it comes to numerical computations. ex: 123456 *837590497023
A normal pentiumII computer will give the answer to this multiplication function instantaneously while a math geek will still take few minutes to get it, possibly with errors.

02. Information storage

computers can store huge amount of information on its hard disk and some amount in their RAM as well. Upgrading or increasing the memory is just a matter of fixing another disk with larger capacity. Only limitation is availability of information. But when it comes to humans, we can keep only a certain amount of knowledge in our memory. Think !!! 80% of things you learnt at Level 1 Semester 1 might be already lost and gone somewhere right now. :)

03. Repetitive Operations

Normally humans get bored and tend to do mistakes as fatigue sets when they do the same thing again and again. On the other hand computers are specifically built to do such tasks.

The above list contains only the mechanical or mindless tasks which normally machines are good at. But "Intelligence" is not that. When performing intelligent tasks humans are far beyond the computers. So what is "intelligence"?

Intelligence is a loosely defined term, and there is no single exact definition a such. In order to possess intelligence, following have been identified as essential to have.

~ to respond to situations flexibly
~ To make sense of ambiguous or erroneous messages.
~ To assign relative importance to elements of a situation.
~ To find similarities even though the situations might be different.
~ To draw distinctions even though the situations look similar.

If intelligence could be defined as above, then following are some tasks that demand intelligence.

~ Speech recognition and understanding
~ Pattern recognition
~ Motion in dynamic obstacle filled space.
~ Mathematical theorem proving
~ Reasoning

I invite you to make an attempt to understand major AI concepts further more by exploring other web resources as well.Here, I did just an introduction only.



Don't forget to become a follower of SeethaGangula.!!!

Monday, October 8, 2012

Check the JDK version in your computer

Do you want to see the JDK version installed in your computer. Then go to Start menu and type "cmd'.
Hit enter. You may be in this kind of a location. In my computer it is C:\Users\Achini>. But you need to be in   just C:

So type like this.
          cd..hit enter. Again type  cd.. hit enter. Do this until you reach the C: drive. Now you should be in C: drive.

     Then type "java -version".
                                                      (java,space,dash,version)


As you can see my JDK version is 1.6 and update 33. Check what is yours.

Don't forget to become a follower of SeethaGangula.!!!

Monday, October 1, 2012

Importance of Fiber (Proven remedies for constipation-1)





Constipation is a common as it can be seen among 2-30% in every population. No doubt it is a hard situation for many patients, specially when they are younger (eg: children) or elderly people. It is not a secret that this is one of the most hard functions of an elderly person's life he has to go through every day. That is why patients having heart disorders are advised to take their TNT bottle when going to toilet, in case to defense themselves from a sudden stroke. To avoid constipation easy steps you can take are,
  1. drinking more water
  2. Adding more vegetables and fruits in to your diet. (natural fiber is best than any other medicine) 
But unfortunately modern people with busy schedules cannot or forget to follow these steps regularly. There are medicines for such situations, which most of them should be taken with medical advice. Namely there are 4 kinds of laxatives.
  • Bulk
  • Osmotic
  • stimulant
  • lubricant
Bulk laxatives are things like Bran, ispagula husk, sterculia, Gam karaya etc. Provided examples include soluble and insoluble fiber. Commercial products are Fibogel, Laxinorm, Normacol and many more. Probably it takes around 12-72 hours for the onset action.

Normally commercially available soluble fiber products are little bit expensive. ex: Benefiber 


What is important with taking soluble fiber is, they can reduce the level of cholesterol in your blood. cholesterol is broken  into something called "Bile" at the digestive system. Bile can be eliminated with soluble fiber.


However bulk laxatives are not recommended for  children. But for elders, fibogel like laxatives can be prepared as a delicious drink and get rid of that unpleasant experience. We'll talk about other types of laxatives in another post.

Don't forget to become a follower of SeethaGangula.!!!