ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
There are 2 methods in a class. Both have the same method
signature except for return types. Is this overloading or
overriding or what is it?
 Question Submitted By :: Maria
I also faced this Question!!     Rank Answer Posted By  
 
  Re: There are 2 methods in a class. Both have the same method signature except for return types. Is this overloading or overriding or what is it?
Answer
# 1
Its a overLoading .because overriding have two diff class 
and return type also same

but overloading have one class,and it have same method name 
and diff signature.
 
Is This Answer Correct ?    2 Yes 4 No
Vikneswarank
[Jadian]
 
  Re: There are 2 methods in a class. Both have the same method signature except for return types. Is this overloading or overriding or what is it?
Answer
# 2
Niether overloading nor ovverriding ,this question has errors

Overloading---->different method
signatures(order,type,number different)
Ovveriding signature same but subclass can implement this method


So ??????????????.
 
Is This Answer Correct ?    7 Yes 1 No
Debapriya
 
 
 
  Re: There are 2 methods in a class. Both have the same method signature except for return types. Is this overloading or overriding or what is it?
Answer
# 3
it is not overloading bcos different return types does not mean overloading.
n 4 overriding inheritance should b used between 2 classes.
so it is neither overriding nor overloading.
 
Is This Answer Correct ?    6 Yes 0 No
Ashu_deepu
 
  Re: There are 2 methods in a class. Both have the same method signature except for return types. Is this overloading or overriding or what is it?
Answer
# 4
If both signature are same, i.e parameters
and if the method has co-variant return type 
which means  return type of int in one method and 
return type of long in another method.
Consider safely as the method is overloaded.

if otherwise it's neither overloaded or overrided
just an another method in the class.
 
Is This Answer Correct ?    0 Yes 3 No
Mohamed Yehiya
 
  Re: There are 2 methods in a class. Both have the same method signature except for return types. Is this overloading or overriding or what is it?
Answer
# 5
See overloading has nothing to do with Covariant Return
types ,in fact overloading dosent take into consideration
the return types.

But in case of ovveriding u can provide Covariant return type

say for example

class A {
 protected A getModel(){
   return this;
  }
}
class B extends A{

  public B getModel(){

     return this
  }
 }
and there are many other examples of 
covariant return types like this.

Since B is A(IS-A RelationShip)
 so the return type can be a subclas of the super class
 
Is This Answer Correct ?    2 Yes 0 No
Debapriya Maity
 
  Re: There are 2 methods in a class. Both have the same method signature except for return types. Is this overloading or overriding or what is it?
Answer
# 6
It is not overloading because overloading must have different parameters, no matter what ever may be the return type is.
And  for overriding inheritance should be used between 2 classes.
so it is neither overriding nor overloading.

It just show compilation error as method is already defined in 
same class
 
Is This Answer Correct ?    5 Yes 0 No
Shamsherabanu
 
  Re: There are 2 methods in a class. Both have the same method signature except for return types. Is this overloading or overriding or what is it?
Answer
# 7
public class sample
{
	public void displayValue (int a, int b)
	{
		System.out.println("a = "+a +" b = "+b);
	}

	public int displayValue (int a, int b)
	{
		System.out.println("a+b:"+(a+b));
		return (a+b);
	}

	public static void main(String[] args) 
	{
		sample t = new sample();
		t.displayValue(10,10);
		int x = t.displayValue(20,30);
	}
}



Output:

D:\Prg>javac sample.java
sample.java:8: displayValue(int,int) is already defined in
sample
        public int displayValue (int a, int b)
                   ^
sample.java:18: incompatible types
found   : void
required: int
                int x = t.displayValue(20,30);
                                      ^
2 errors
 
Is This Answer Correct ?    2 Yes 0 No
S.ramesh
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
is this possible to create an array of 0 length? if so how? if not so why? coz we have an array in main() likw this "static void main(String [] s) then what it signifies? Hexaware2
what is meant by UP& DOWN casting in java?  4
What is Session and cookies?Explain in detail with an example? CTS2
class A{ some variables; public void a()throws Excepion1,Exception2{....} } class B extends A{ variables... public void a()throws E2,E3{.....} } Qns: here override of methods occurs or not,ore else wil give any compilation error or run properly..plz tell me briefly whts happening with the above codes.... Quinnox3
Hi Friends, I am beginner in java. what i know about synchonized keyword is,If more that one 1 thread tries to access a particular resource we can lock the method using synchronized keyword. Then after that how the lock is released and how next thread access that.Please explain with example.  1
To set the position and size of a component, which methods are used?  2
Can you explain the difference b/n abtract and interface with a good example,?In what cases we have use abtract and what case interface? Satyam1
How to send a request to garbage collector?  3
Functionality of JVM? Infosys4
I have an HashMap object, which has with key and value pair. It has 10 keys and values in that object. Now the question is I want insert new key and value in middle or any where in that list but not at the end or at the top. Is it possible or not. If yes how can we achieve this one? Huawei1
What is the difference between serialization and deserialization? ABC2
What are init(), start() methods and whey they are called?  2
what is the Diff. between Access Specifiers and Access Modifiers? Wipro15
What methods are called, When we navigate from one applet to another applet?  1
What class is used to implement a Throwable array?  3
basic difference b/w ALL types of JDBC driver. Systematix1
AWT event listeners extends what interface?  1
what is mutability?which one is mutable String or StringBuffer?and why?give examples of each which shows the mutability of each String or StringBuffer  2
What is the difference between pageContext and page implicit objects in jsp? Merrill-Lynch6
what are the differences between final,finally,finalize methods?  7
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com