13-02-2010, 08:36 AM | #1 |
Member
Join Date: Dec 2009
Posts: 50
Rep Power: 15 |
Java Interview Questions :: Challenging all Java Developers
Which programming language was the main inspiration behind the development of Java? |
14-02-2010, 09:59 AM | #2 |
Member
Join Date: Dec 2009
Posts: 42
Rep Power: 0 |
Java is inspired from smalltalk, one of the first object oriented programming languages..
|
18-02-2010, 08:36 PM | #3 |
Member
Join Date: Jan 2010
Posts: 243
Rep Power: 16 |
Now my question.. what are marker interfaces and its advantages? Why we use marker interfaces?
|
13-03-2010, 05:00 PM | #4 |
Senior Member
Join Date: Dec 2009
Posts: 444
Rep Power: 18 |
A so-called marker interface is a Java interface which doesn't actually define any fields. It is just used to "mark" Java classes which support a certain capability -- the class marks itself as implementing the interface.
There are few Java supplied marker interfaces like Cloneable, Serializable, etc. One can create their own marker interfaces the same way as they create any other interface in Java. The main purpose to have marker interfaces is to create special types in those cases where the types themselves have no behavior particular to them. If there is no behavior then why to have an interface? Because the implementor of the class might only need to flag that it belongs to that particular type and everything else is handled/done by some other unit - either internal to Java (as in the case of Java supplied standard marker interfaces) or an app specific external unit.
__________________
Join this forum, it's completely free. |
14-03-2010, 07:59 PM | #5 |
Member
Join Date: Dec 2009
Posts: 45
Rep Power: 0 |
My question..
When destory method is called in servlet life cycle? |
16-03-2010, 04:46 PM | #6 |
Member
Join Date: Mar 2010
Posts: 16
Rep Power: 0 |
The destroy() method is usually called by the servlet container immediately before it takes a servlet out of service. It is typically used to clean-up any resource references, save temporary data and suchlike. For example, it is called during server restart..
|
17-03-2010, 10:02 PM | #7 |
Senior Member
Join Date: Dec 2009
Posts: 444
Rep Power: 18 |
Next question.. What is the difference between call by value and call by reference?
__________________
Join this forum, it's completely free. |
18-03-2010, 07:23 AM | #8 |
Member
Join Date: Dec 2009
Posts: 64
Rep Power: 15 |
The arguments passed to function can be of two types namely
1. Values passed 2. Address passed The first type refers to call by value and the second type refers to call by reference. For instance consider program1 Code:
main() { int x=50, y=70; interchange(x,y); printf(“x=%d y=%d”,x,y); } interchange(x1,y1) int x1,y1; { int z1; z1=x1; x1=y1; y1=z1; printf(“x1=%d y1=%d”,x1,y1); } Here the value to function interchange is passed by value. Consider program2 Code:
main() { int x=50, y=70; interchange(&x,&y); printf(“x=%d y=%d”,x,y); } interchange(x1,y1) int *x1,*y1; { int z1; z1=*x1; *x1=*y1; *y1=z1; printf(“*x=%d *y=%d”,x1,y1); } Here the function is called by reference. In other words address is passed by using symbol & and the value is accessed by using symbol *. The main difference between them can be seen by analyzing the output of program1 and program2. The output of program1 that is call by value is x1=70 y1=50 x=50 y=70 But the output of program2 that is call by reference is *x=70 *y=50 x=70 y=50 This is because in case of call by value the value is passed to function named as interchange and there the value got interchanged and got printed as x1=70 y1=50 and again since no values are returned back and therefore original values of x and y as in main function namely x=50 y=70 got printed. |
26-03-2010, 07:55 PM | #9 |
Senior Member
Join Date: Dec 2009
Posts: 444
Rep Power: 18 |
nice explanation with examples.. thanks for sharing.. Next question please..
__________________
Join this forum, it's completely free. |
27-03-2010, 07:47 PM | #10 |
Member
Join Date: Dec 2009
Posts: 33
Rep Power: 0 |
Next question from my side.
What are wrapper classes in Java? |
Bookmarks |
Tags |
java quiz |
|
|