hello, I am begginer in JAva. I had been to one interview. They asked me following questions. It will be very useful if i get some clarification about these.
1. what is the difference between overloading and overrideing. where overriding is used? overloading is same method name with different no. of orguments, return type and orgument data type. overriding--no idea. 2. what is the use of "static" infront of a class, a method and a variable? no idea at all. (variables, can be accessed without creating a handle for it) 3. Can main method overloaded or overriden? Can't be overloaded as it accepts only String type of comman lind orguments. no idea about overriding. 4.what is the difference between static and final?--final is a constant. whose value can't be changed. No idea about difference 5. what is the difference between static polymorphism and dynamic polymorphism, give examples.--no idea 6. what is the difference between extends and implements. I think extends is for single inheritance where as implements is for multiple inheritance.
I'll suggest you to go through some book like Headfirst or Thinking in Java before appearing for any more interviews. All the questions are quite elementary and can easily be found in a beginner book. So, go through a book first and then if you have any doubts, which you will, post it here. In that way, you will learn better.
SCJP 1.4 85%
Joined: Feb 14, 2006
I wonder if there is a concept like Static Polymorphism. Technically, isn't polymorphism supposed to be runtime?
I just reply what I know. If there are any wrong points , please tell me.
1. Overload : means that methods with different type of parameters.Take "valueOf" as example: there are many versions of method valueOf , such as valueOf(boolean b)、valueOf(int i)、valueOf(char c)...etc. According to the different type of arguments , calling corresponding methods. Override : means re-defined super class's methods. When you extends super class , you got some methods from it. But it is not agree with you at all. In this situation , you can "override" the method. For example:
[ July 22, 2006: Message edited by: kevingo ]
Joined: Jul 22, 2006
2. What is static? Let me take "Math" class for example. Some methods or data is useful and we want to call them easily. What should we do? For example:
See? I do not new a Math object to call the method "abs(int i)". Such as : It is wrong! Because the declaration of abs() is
When a method or variable declare as static , you must use className.methodName or className.variableName to call them. The static members are owned by class , not object.
Please revise your display name to meet the JavaRanch Naming Policy. To maintain the friendly atmosphere here at the ranch, we like folks to use real (or at least real-looking) names, with a first and a last name.
It sounds like this was a good experience, because now you know some of the things you need to study! A good introductory book would help you a lot. I suggest Head First Java by Kathy Sierra and Bert Bates.
You can also download a free copy of Bruce Eckel's Thinking in Java (3rd edition) from the author's website -- although you should note that this edition does not cover any new features of Java 5.0.
Joined: Jul 22, 2006
Dear "Marc Weber" , I have known that naming policy after I post the reply, now I have change my name. Thank you for your attention.