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
What is the difference between this() and super()?
 Question Submitted By :: Amarmca84
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the difference between this() and super()?
Answer
# 1
this() can be used to invoke a constructor of the same class
whereas super() can be used to invoke a super class constructor.
 
Is This Answer Correct ?    16 Yes 0 No
Amarmca84
[Amar]
 
  Re: What is the difference between this() and super()?
Answer
# 2
this() should be first statement in the constructor of the 
same class and you cannot call this() in other places
 
Is This Answer Correct ?    2 Yes 2 No
Kraja
 
 
 
  Re: What is the difference between this() and super()?
Answer
# 3
Super should be used only in the sub classes and super() is 
used to point methods of super class. where as this can be 
used in both super & sub classes and this() used to point 
methods in the class where it is called.
 
Is This Answer Correct ?    4 Yes 0 No
Gcttcs
 
  Re: What is the difference between this() and super()?
Answer
# 4
super is the first statement of derived class constuctor.

class room
{
 int l,b;
 room(int x,int y)
 {
   l = x;
   b = y;
 }
 void area()
 {
   int a;
   a = l*b;
   return(a);
 }
}
class studyroom extend room 
{
 int h;
 studyroom (int x ,int y, int z)
 {
  super(x,y)
  z = h;
 }
 int volume()
{
  int v;
  v = l*b*h;
  return(v);
}
} 
class sup
{
 public static void main(String args[])
{
  int ar,vol;
  studtroom s=new Studyroom()
  ar = s.area();
  vol = s.volume();
  System.out.println("the area is = "+ar);
  System.out.println("the volume is = "+vol);
}
}
 
Is This Answer Correct ?    4 Yes 0 No
Ankita Jain
 
  Re: What is the difference between this() and super()?
Answer
# 5
1)Super() always calling the constructor of immediate  
super  class, super() must always be the first statements 
executed inside a subclass constructor.

2)You cannot use this() and Super() in the same constructor.
 
Is This Answer Correct ?    2 Yes 0 No
Prabu.b
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
Is 'sizeof' a keyword?  3
what ide u r using and wat version, how wil u build the project etc ?  2
What is an abstract class? Wipro5
Differentiate Vector and ArrayList? Wipro3
what is the difference between AWT and SWING what is the advantage of using swing?  2
Explain Connection Pooling?  2
what is difference betwwen hashmap and hashtable ? Fidelity5
What is the immediate superclass of Menu?  1
can any one tell me when do u go for inheritance and polymorphism  1
Is java supports multiple inheritance? explain? Inforica9
What is unicode?  2
write a simple program inheritance? Polaris1
can you program for reverse string? IBM4
What is I/O Filter? TCS1
What are the Object and Class that classes used for?  2
When you Click a Button, What event will be fired?  1
What is the purpose of finalization?  3
what is difference between abstraction and interface? FIC5
what is difference between servletconfig and servletcontext? AMDOC2
public class AboutStrings{ public static void main(String args[]){ String s1="hello"; String s2="hel"; String s3="lo"; String s4=s2+s3; //to know the hash codes of s1,s4. System.out.println(s1.hashCode()); System.out.println(s4.hashCode()); // these two s1 and s4 are having same hashcodes. if(s1==s4){ System.out.println("s1 and s4 are same."); }else System.out.println("s1 and s4 are not same."); } } Somebody told me that, == operator compares references of the objects. In the above example even though s1 and s4 are refering to same object(having same hash codes), it is printing s1 and s4 are not same. Can anybody explain in detail why it is behaving like this? Thanks in Advance RavuriVinod TCS3
 
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