My Hindi Forum

Go Back   My Hindi Forum > Miscellaneous > Tech Talks
Home Rules Facebook Register FAQ Community

Reply
 
Thread Tools Display Modes
Old 13-02-2010, 08:36 AM   #1
javaguru
Member
 
javaguru's Avatar
 
Join Date: Dec 2009
Posts: 50
Rep Power: 15
javaguru is on a distinguished road
Question Java Interview Questions :: Challenging all Java Developers

Hi all Java developers of abhisays.com Discussion zone. I am starting a new thread of Java interview questions.. I will ask small questions and you have to answer.. The person who will answer maximum number of questions correctly will be awarded the title of Java Geek.. Let's start the quiz..and best of luck to all members..

Which programming language was the main inspiration behind the development of Java?
javaguru is offline   Reply With Quote
Old 14-02-2010, 09:59 AM   #2
umesh
Member
 
umesh's Avatar
 
Join Date: Dec 2009
Posts: 42
Rep Power: 0
umesh is on a distinguished road
Wink

Java is inspired from smalltalk, one of the first object oriented programming languages..
umesh is offline   Reply With Quote
Old 18-02-2010, 08:36 PM   #3
sony
Member
 
sony's Avatar
 
Join Date: Jan 2010
Posts: 243
Rep Power: 16
sony has a spectacular aura aboutsony has a spectacular aura about
Default

Now my question.. what are marker interfaces and its advantages? Why we use marker interfaces?
sony is offline   Reply With Quote
Old 13-03-2010, 05:00 PM   #4
abhishek
Senior Member
 
abhishek's Avatar
 
Join Date: Dec 2009
Posts: 444
Rep Power: 18
abhishek is just really niceabhishek is just really niceabhishek is just really niceabhishek is just really nice
Default

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.
abhishek is offline   Reply With Quote
Old 14-03-2010, 07:59 PM   #5
rambler
Member
 
rambler's Avatar
 
Join Date: Dec 2009
Posts: 45
Rep Power: 0
rambler is on a distinguished road
Default

My question..

When destory method is called in servlet life cycle?
rambler is offline   Reply With Quote
Old 16-03-2010, 04:46 PM   #6
shefali
Member
 
shefali's Avatar
 
Join Date: Mar 2010
Posts: 16
Rep Power: 0
shefali is on a distinguished road
Default

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..
shefali is offline   Reply With Quote
Old 17-03-2010, 10:02 PM   #7
abhishek
Senior Member
 
abhishek's Avatar
 
Join Date: Dec 2009
Posts: 444
Rep Power: 18
abhishek is just really niceabhishek is just really niceabhishek is just really niceabhishek is just really nice
Default

Next question.. What is the difference between call by value and call by reference?
__________________
Join this forum, it's completely free.
abhishek is offline   Reply With Quote
Old 18-03-2010, 07:23 AM   #8
sunita
Member
 
sunita's Avatar
 
Join Date: Dec 2009
Posts: 64
Rep Power: 15
sunita is on a distinguished road
Wink

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.
sunita is offline   Reply With Quote
Old 26-03-2010, 07:55 PM   #9
abhishek
Senior Member
 
abhishek's Avatar
 
Join Date: Dec 2009
Posts: 444
Rep Power: 18
abhishek is just really niceabhishek is just really niceabhishek is just really niceabhishek is just really nice
Default

nice explanation with examples.. thanks for sharing.. Next question please..
__________________
Join this forum, it's completely free.
abhishek is offline   Reply With Quote
Old 27-03-2010, 07:47 PM   #10
swati.
Member
 
swati.'s Avatar
 
Join Date: Dec 2009
Posts: 33
Rep Power: 0
swati. is on a distinguished road
Default

Next question from my side.

What are wrapper classes in Java?
swati. is offline   Reply With Quote
Reply

Bookmarks

Tags
java quiz


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT +5. The time now is 03:45 AM.


Powered by: vBulletin
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
MyHindiForum.com is not responsible for the views and opinion of the posters. The posters and only posters shall be liable for any copyright infringement.