aspose file tools*
The moose likes Beginning Java and the fly likes Interview questions?plz answer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Interview questions?plz answer" Watch "Interview questions?plz answer" New topic
Author

Interview questions?plz answer

kesava chaitanya
Ranch Hand

Joined: Aug 15, 2001
Posts: 140
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

Joined: Apr 04, 2004
Posts: 815
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.'


I've heard it takes forever to grow a woman from the ground
Venkatraman Kandaswamy
Ranch Hand

Joined: Jul 07, 2004
Posts: 120
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 ]

--Venkatraman<br />SCJP 1.4<br /><a href="http://kvrlogs.blogspot.com" target="_blank" rel="nofollow">blog</a>
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19073
    
  40

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 ]

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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


Java API Documentation
The Java Tutorial
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Interview questions?plz answer