Having the same method in the subclass as declared in the parent class is known as method overriding. If a subclass provides a specific implementation of a method that is already provided by its super class, it is known as Method Overriding.

Advantages :

1) Method Overriding is used to provide specific implementation of a method that is already provided by its super class.

2) Method Overriding is used for Runtime Polymorphism.

Rules :

1) method must have same name as in the parent class.

2) method must have same parameter as in the parent class.


class Animal{ void eat(){System.out.println("eating");} } class Human extends Animal{ void eat(){System.out.println("eating delicious food");} public static void main(String args[]){ Human h= new Human(); h.eat(); }
}

Output eating delicious food

 
JAVA TUTORIALS HOMEPAGE


The static keyword is used in java mainly for memory management. We may apply static keyword with variables, methods and blocks. The static keyword belongs to the class than instance of the class. The static can be:

  • variable
  • method
  • block
Static variable :
If you declare any variable as static, it is known static variable.

1) The static variable can be used to refer the common property of all objects (that is not unique for each object) e.g. company name of employees,college name of students etc.

2) The static variable gets memory only once in class area at the time of class loading.


class Student{
int id;
String address;
static String college ="Rkgit";

Student(int id,String address){
this.id=id;
this.address=address;
}

void displayRecord(){
System.out.println(id+" "+address+" "+college);
}

public static void main(String args[]){
Student s1=new Student(112,"new delhi");
Student s2=new Student(119,"ghaziabad");

s1.displayRecord();
s2.displayRecord();
}
}

Static method :

If you apply static keyword with any method, it is known as static method.

1) A static method belongs to the class rather than object of a class.

2) A static method can be invoked without the need for creating an instance of a class.

3) Static method can access static data member and can change the value of it.


class A{

static int cube(int n){
return (n*n*n);
}

public static void main(String args[]){
System.out.println(cube(3));
}
}


Static block :

1) It is used to initialize the static data member.

2) It is excuted before main method at the time of classloading.


class A{

static {
System.out.println("static block is executed");}

public static void main(String args[]){
System.out.println("main method executed");
}




                                     JAVA TUTORIALS HOMEPAGE







































Constructor is a special type of method that is invoked at the time of object creation. It is used to initialized the object.

RULE :
1) Its name must be same as class name.
2) It must not have any explicit return type.

TYPE

  • Default
  • Parameterized
Default Constructor :
A constructor that have no parameter is known as
default constructor.

class Bike{
Bike(){System.out.println("Bike is created");}
public static void main(String args[]){
Bike b=new Bike();
}



Output: Bike is created

Rule: If there is no constructor in a class, compiler automatically creates a default constructor.

Parameterized constructor :
A constructor that have parameter is known as parameterized constructor.

Parameterized constructor is used to provide different values to the distinct objects.

In this example, we have created the constructor of Student class that have two parameters. We can have any number of parameters in the constructor.

class Student{
    int id;
    String name;
    
    Student(int i,String n){
    id = i;
    name = n;
    }
    void display(){System.out.println(id+" "+name);}

    public static void main(String args[]){
    Student s1 = new Student(111,"Karan");
    Student s2 = new Student(222,"Aryan");
    s1.display();
    s2.display();
   }
}





Output : 111 Karan
        222 Aryan


                    JAVA TUTORIALS HOMEPAGE





Android 4.1, Jelly Bean: The world's most popular platform gets even better :






android jelly bean :: futureX

 


Fast & smooth:

With buttery graphics and silky transitions, moving between home screens and switching between apps is effortless, like turning pages in a book.
More reactive and uniform touch responses mean you can almost feel the pixels beneath as your finger moves across the screen. Jelly Bean makes your Android device even more responsive by boosting your device's CPU instantly when you touch the screen, and turns it down when you don't need it to improve battery life.

Expandable, actionable notifications:

Android has always put you in control when it comes to staying notified and connected. Now you can take action directly from the notifications shade. Late for a meeting? Email everyone to let them know. Missed a call? Call them back in an instant. And because they’re expandable, you can get an even deeper look into the things that matter most, like multiple emails or photos on Google+.

Widgets work like magic:

With Jelly Bean it's now even easier to personalize your home screen. As you place widgets on the screen, everything else automatically moves to make room. When they're too big, widgets resize on their own. Interacting with your favorite apps and customizing your home screen has never been easier.




Seamlessly take and share photos:

Android 4.0, Ice Cream Sandwich, made snapping photos super fast; Jelly Bean brings that same speed to the next step: viewing. Just swipe over from camera to filmstrip view to instantly view the photos you just took, and quickly swipe away the ones you don’t like. Now sharing — and bragging — are a breeze.

A smarter keyboard:

Android's dictionaries are now more accurate, more relevant. The language model in Jelly Bean adapts over time, and the keyboard even guesses what the next word will be before you've started typing it. With improved text-to-speech capabilities, voice typing on Android is even better; it works even when you don't have a data connection, so you can type with your voice everywhere you go.

Android Beam:

With Android Beam on Jelly Bean you can now easily share your photos and videos with just a simple tap, in addition to sharing contacts, web pages, YouTube videos, directions, and apps. Just touch two NFC-enabled Android devices back-to-back, then tap to beam whatever's on the screen to your friend. Instantly pair your Android phone or tablet to Bluetooth® devices like headsets or speakers that support the Simple Secure Pairing standard by just tapping them together – no more syncing or searching required.

Voice Search:

Sometimes you'd rather just speak your search query. Or just ask a question. Android lets you search the web with your voice, and it's convenient for getting quick answers on the fly. It speaks back to you and is powered by the Knowledge Graph, bringing you a precise answer if it knows it, and precisely ranked search results, so you can always find out more.






In same class, if name of the method remains common but the number and type of parameters are different, then it is called method overloading in Java.

java method overloading :: futureX
let's see a example :                                        


public class Overload {

void add(int m, int n) 
{
int sum = m + n;
System.out.println( "Sum of a+b is " +sum);


void add(int a, int b, int c) {

int sum = a + b + c;
System.out.println("Sum of a+b+c is " +sum);

}

void add(double a, double b) { 

double sum = a + b;
System.out.println("Sum of a+b is "+sum);
}

void add(String s1, String s2)
{
String s = s1+s2;
System.out.println(s);
}
}
class overloadfunc{ 

public static void main(String args[])
{
Overload2 obj = new Overload2();

obj.add(4,19);

obj.add(4,17,11);

obj.add(1.5,21.5);

obj.add("Life at"," the speed of rail ");
}

}



Output will be:
Sum of a+b is 23
Sum of a+b+c is 32
Sum of a+b is 23.0
Life at the speed of rail


                      JAVA TUTORIALS HOMEPAGE
Copyright © 2013 futureX | Blogger Template by Clairvo