• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interview questions?plz answer

 
kesava chaitanya
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i have some interview questions;can anybody share with me?

1.what is meant by static variable and static method with an example?what r the uses?;

2.what r the uses of Interfaces over abstract class?

3.Name two interfaces without method?

4.what is meant by polymorphism?explain with an example?

5.what is meant by deadlock?

6.what is meant by time-slicing?

7.how can u set input and output parameters using Callablestatement with an example?

8.what is difference between throw and throws?
 
Nick George
Ranch Hand
Posts: 815
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the acronym... something about go to f'ing google? As for polymorphism, I think there's something about a dog learning polymorphism somewhere on this site... I'll find a link for you if you promise to change the word 'r' to 'are.'
 
Venkatraman Kandaswamy
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here are your answers. But do more research.

1.what is meant by static variable and static method with an example?what r the uses?;

Suppose you want to count the number of objects that are instantiated - you cannot use a member variable as its scope is limited to the instantiated object. So you use a static variable - which can be accessedby all the objects instantiated from that class. So whenever an object is instantiated, in the constructor increment the static variable. You can get a count of all the objects instantiated.

Also with static variables and methods you need not instantiate the class to access them. Just have <classname>.<variablename> or <classname.methodname>. The best example is Math class functions - all are static methods.



2.what r the uses of Interfaces over abstract class?

Interfaces - for polymorphism
abstract - for inheritance

3.Name two interfaces without method?

**shrugs**

4.what is meant by polymorphism?explain with an example?

Overloaded methods is an example of polymorphism. The other type of polymorphism is when you implement an interface. At run time the correct method call is made based on the argument type.

5.what is meant by deadlock?

Assume there are 2 threads A and B. A waits for a resource held by B to be released and B waits for a resource held by A. So both threads keep staring at each other.

6.what is meant by time-slicing?

Java does not reveal to you how its going to schedule its threads. Time slicing is when each thread gets a certain amount of time to run - perhaps?

7.how can u set input and output parameters using Callablestatement with an example?

8.what is difference between throw and throws?



throws is to do with declaring that an exception might be thrown and throw is where you throw the actual exception.

Good luck.
[ November 07, 2004: Message edited by: venkatraman kandaswamy ]
 
Henry Wong
author
Marshal
Pie
Posts: 21437
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While some of these questions are somewhat obscure, most are basic. (i.e. the "throw/throws" question is a language 101 question) Finding out what you need to know from an interview is not a good idea... unless you are talking about a practice interview, of course.

Anyway, I will try to add one answer:

3.Name two interfaces without method?


A case where you want to have an interface without any methods, is so that you can check if an object is a particular type, using the instanceof keyword.

For some reason, I am drawing a blank, but one example is the Remote interface. I don't think it actually have any methods, but classes that implement it are remote objects.

Okay, I think the other one is the serializable interface.

Hope this helps,
Henry
[ November 07, 2004: Message edited by: Henry Wong ]
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Henry Wong:
While some of these questions are somewhat obscure, most are basic. (i.e. the "throw/throws" question is a language 101 question) Finding out what you need to know from an interview is not a good idea... unless you are talking about a practice interview, of course.

Anyway, I will try to add one answer:



A case where you want to have an interface without any methods, is so that you can check if an object is a particular type, using the instanceof keyword.

For some reason, I am drawing a blank, but one example is the Remote interface. I don't think it actually have any methods, but classes that implement it are remote objects.

Okay, I think the other one is the serializable interface.

Hope this helps,
Henry

[ November 07, 2004: Message edited by: Henry Wong ]


Cloneable also falls in this category. However, this is not the only reason to create an interface without methods. Another reason is if you want to group a set of constants together. SwingConstants is an example of this. I'm sure there are others as well, but none come to mind at the moment.

I agree that several of these questions are about understanding basic Java syntax and semantics. You should google to find more about polymorphism, interface, abstract classes, etc. These are all fundamental topics in Java, so it isn't surprising that they would show up in an interview. Also, you may want to invest in a book or two that describe these things. I started learning Java with the Core Java series. You should check these out.

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic