>

Sunday, December 16, 2012

Travelling Guide -ROUTES


ROUTES-AN NGO
Every day numerous people travelling towards Chennai. But most of them were not aware of Chennai Bus routes. For those who new to Chennai or People do not have idea about Chennai bus routes can utilize this facility provided by an NGO called ROUTES.
Just call this number from Chennai. You will get help about all bus routes in Chennai. This service is provided at free of cost...
8695959595

...

Also do not forgot to post your comments...

Java String Program

Given a string, take the first 2 chars and return the string with the 2 
chars added at both the front and back, so "kitten" yields"kikittenki". 
If the string length is less than 2, use whatever chars are there.

My Own program follows:

public class FrontTwo {


    public static void frontT(String str)
    {
        if(str.length()>=2){
          
          
            String temp=str.substring(0, 2);
            System.out.println(temp+""+str+""+temp);
            }
            else if(str.length()<2)
            {
                String temp=str.substring(0);
                System.out.println(temp+""+str+""+temp);
            }
            else
            {
                System.out.println(str);
            }
      
    }

         public static void main(String[] args) {

        frontT("hai");

    }

}

Java program using Constructor

What is the output?

public class SaravananK {

    static int x=4;

    public SaravananK() {

        System.out.print(this.x);

          }   
public static void main(String[] args) {
     
         System.out.println(new SaravananK().x);
    }

}

Java program using Dot Dot Dot (String ... args)

public class DotDotDot {

    public static void main(String... args) {
       

        System.out.println("this will work? or not");

    }

}

Java program using While loop

What is the out put?
public class ThisNumber {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

       
        int the_number=4;
        int that_number;
        while(the_number<10)
        {
            that_number=the_number;
            the_number=the_number+that_number/2;
        }
        System.out.println(the_number);
    }
   

}

An Java program using inheritance

An Java program using inheritance :

class BaseA
{
    public BaseA(){
       
        System.out.println("Base A constructor");
    }
   
    public void methodOne(){
        System.out.println("Method one in base A");
    }
}

class BaseB extends BaseA{

    public BaseB(){
        super();
        System.out.println("Base b constructor");
    }
    public void methodOne(){

        BaseA ba=new BaseA();
        ba.methodOne();
        System.out.println("Method one in base B");
    }
}

public class Base{
   
    public static void main(String args[])
    {
        BaseA ba=new BaseB();
        BaseB bb=new BaseB();
        ba.methodOne();
        bb.methodOne();
        Base base=new Base();
       
       
    }
    public static void main(String args[][])
    {
        BaseA ba=new BaseA();
    }
}

Saturday, December 15, 2012

Java Inner Class

What is out put?

// A program using in inner class and method over loading
class Outer{
   protected int a=6;
   public void methodOne(){
       a=a++;
       System.out.println("In methodOne outer class a "+a);
   }
       class Inner{
          
            public void methodOne(){
                int a=6;
                System.out.println("In method one value of a "+a);
            }
            public void methodTwo(){
                a=a--;
                System.out.println("In method two value of a "+a);
            }
       }
       public void methodTwo(){
           System.out.println("In outerclass method Two value of a "+a);
       }
      
}
public class Test {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        Outer out=new Outer();
        Outer.Inner in=out.new Inner();
        out.methodOne();
        in.methodOne();
        in.methodTwo();
        out.methodTwo();
       
    }

}