BINDING ;

> A like as, binding is a two types . There are below the line.

> DYNAMIC BINDING

> STATIC BINDING

DYNAMIC BINDING ;

> *!Dynamic binding or late binding!* is the mechanism a computer program waits until runtime to bind the name of a method called to an actual subroutine.

> It is an alternative to early binding or static binding where this process is performed at compile-time.

PROGRAM ;

> public class FastFood {
public void create() {
System.out.println(“Cooking a FastFood “);
}
}


public class Pizza extends FastFood {
public void create() {
System.out.println(“Cooking a Pizza hunt”);
}
}


public class Main {
public static void main(String[] args) {


FastFood fastFood= new FastFood();
fastFood.create();
//Dynamic binding


FastFood pza= new Pizza();
pza.create();
}
}

FINAL METHOD ;

> the final keyword is used to denote constants.

> It can be used with variables, methods, and classes.

> Once any entity (variable, method or class) is declared final , it can be assigned only once.

PROGRAM ;

class FinalDemo {
// create a final method


public final void display() {
System.out.println(“This is a final method.”);
}
}



class Main extends FinalDemo {
// try to override final method


public final void display() {
System.out.println(“The final method is overridden.”);
}



public static void main(String[] args) {
Main obj = new Main();
obj.display();
}
}

DOUBLE LOOP ;

Public class line3 {

Public static void main (String[]args) {

Int a = 1 ; Int b = 2;

For(int i = 1; i<=5; i++) {

For( int j = 0; j<=5 ; j++) {

If( j%2 == 0)

System.out.print(a);

Else {

System.out.print(b);

}

}

System.out.print(\n);

Int Temp = a ;

a = b ;

b = temp ;

}

}

}

Leave a Comment