nishith mishra said...
interface Callback {
void callback(int param);
}
class Client implements Callback {
// Implement Callback's interface
public void callback(int p) {
System.out.println("callback called with " + p);
}
}
class TestIface {
public static void main(String args[]) {
Callback c = new Client();
c.callback(42);
}
}
here it has been created "Callback c"...how is it possible????????
please tell me with suitable example
Dear Nishith,
"i do have a doubt about interfeces .
as we know dat we can not instantiate interface"
Let me clear it that interfaces CAN be instantiated.
It is abstract classes that should NOT be instantiated.
Now about the example you have given:
The statement is :
Callback c = new Client();
Here 'c' is nothing but a generic reference which is having 'Static reference of type Callback' & 'Dynamic reference of type Client'.
So when you call c.callback(42); the Dynamic type governs the method selection so Client's
callback() method will get called.
Here I am giving one example for your reference:
As we do in the simple hierarchy of classes : Emp-WageEmp
so,
Emp e1 = new WageEmp();
e1.display();
in above case Emp can be an interface implemented by WageEmp or a parent class of WageEmp.
so here, e1.display() will call display method of WageEmp class.
I hope this answers you doubt.
Note: Here onwards please post your queries/doubts in the "Queries section" tab created separately.
How to lock folder without using software:
ReplyDelete1)Download locker.txt
2)Create a folder with name 'Private' in "D" drive.
3)Don't make mistake in upper case and in lower case in folder creation.
4)Open locker.txt file.
5)See following line in this locker.txt file
"title Folder Private"
6)If you are using another folder then change "Private" keyword with another folder name.
7)See following line in this locker.txt file
"if NOT %pass%== password here goto FAIL"
8)Change "password here" with your password.example password here=1234---->password
9)Save this file in D drive with name locker.bat
10)Then on D drive you can see system file name "locker"
11)Double click on "locker" and then you are see command prompt type window
12)Type 'y' and press "Enter" key
13)When you done this procedure then you can see D drive.You can't see Private folder.
14)If you want unlock folder then double click on "locker" again
15)Type password and press "Enter"
16)You can see now your private folder.
Hey Nice1... It works...:-)
ReplyDeleteThank u sir...
ReplyDeleteanother technique is from command prompt.i will post it later..
nice technique its really works...
ReplyDeletehello sir this is Ajinkya
ReplyDeleteHow to add applet code in JSP.
hello sir,this is rahas rani
ReplyDeletewhich is the best collection class among all,why should we use it??