Sunday, 29 June 2014

What is Abstract Class in Java

Here are the points related Abstract class in Java that shall clear about Abstract word
  1. Abstract class is the one of class that cannot be instantiated.
  2. If you want to get implementation of any method from child class(other person) then abstract method can use in this sense.
  3. Abstract class are incomplete ,subclass must declare missing piece to become concrete class(Class whose object can be instantiated ) , otherwise these subclass also become abstract class.
  4. You can achieve abstraction that is main pillar of OOP through by "abstract classes".
  5. Abstraction hide the irrelevant detail of an object.
  6. Abstract use for IS A Relationship (Inheritance).
  7. Abstraction use for to achieve Polymorphic behavior (Another main pillar of OOP)   
Here is example of abstract class
   abstract public Employee{

         abstract public void earning();// abstract method

         public void showAge(){//concrete method
                System.out.println("My Age ??");
          }
   }

   8. abstract class should not be private and not contained private method.
   9.  You extends single abstract class not multiple because Java is Single supported Inheritance
   10.  Abstract class must contain  1 or more than 1 abstract method
   11.  If any class contain abstract method then it should explicitly declare abstract class even if it contain 
        concrete method.
   12. Constructor and static method cannot be declared as abstract because constructor are not inherited.

   public class HourlyEmployee extends Employee{
             
        public void earning(){// Implementation of  Abstract Method
                System.out.println("My Earning ");
        }

      @Override
      public void showAge(){
                System.out.println("My Age ??");
      }
   }//end of class

   13. If child class have not implement the abstract method of super class then it become also abstract class.
   14. Attempting to instantiate the object of abstract class is an Compilation error.
   15. Abstract super class variable can hold the reference of child concrete object.


     Employee e=new HourlyEmployee();

Friday, 27 June 2014

Why Java

If you want to learn OOP (Object Oriented Programming) with learning Programming then Java is the top most and recommended  Proramming language.Here is the following why I said above statement



  • Java Inherit from C and C++ language ; if you know C /C++ language then there is no problem for you to learn instead from scratch
  • Java is Pure Object Oriented
     All work in the Java is in Classes and objects that is the key element of OOP.
    public class Welcome{
           public static void main(String []args){
                System.out.println("Welcome to my Blog);
    }
    }

    In the above program of Java , If you want to take little bit from Java then you should work in the classes
  • It's give you more than 5000 built in classes that make your easier and faster.
    E.g : If you want to make connection to other using WEB then you can use java.net package.
  • You can run your own Java Application in to any other Platform.
  • There are larger community and forums for Java ,if you feel and face any sort of problem then you may ask
  1.  StackOverflow
  2. Programmer
  3. CodeRanch
  4. Android.Developer