aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes return super.getC(); equals to return this.getC(); Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "return super.getC(); equals to return this.getC();" Watch "return super.getC(); equals to return this.getC();" New topic
Author

return super.getC(); equals to return this.getC();

Folkert Meeuw
Greenhorn

Joined: Nov 25, 2009
Posts: 21


The syntax for calling a superclass constructor is

super();
--or--
super(parameter list);

With super(), the superclass no-argument constructor is called. With super(parameter list), the superclass constructor with a matching parameter list is called.


Is super. in this case the equal use like this. ?


Ankur kothari
Ranch Hand

Joined: Sep 06, 2009
Posts: 531
this. refers to current object, ....super. refers to superclass variables or .....
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

in this case the equal use like this. ?


I am not sure I understood that correctly. Can you elaborate on your question a little more ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Folkert Meeuw
Greenhorn

Joined: Nov 25, 2009
Posts: 21
Deepak Bala wrote:
in this case the equal use like this. ?


I am not sure I understood that correctly. Can you elaborate on your question a little more ?


Hello Deepak Bala:

What I know is:


What I didn't know 'til yet is:
Kedar Sarmalkar
Greenhorn

Joined: May 25, 2007
Posts: 16
Folkert Meeuw wrote:

The syntax for calling a superclass constructor is

super();
--or--
super(parameter list);

With super(), the superclass no-argument constructor is called. With super(parameter list), the superclass constructor with a matching parameter list is called.


Is super. in this case the equal use like this. ?





First thing... the code that you have randomly put here.... did you ever try it on your own.... it has infinite errors..... the super.d won't work as d is private in A, and is there any new style of writing methods where in they return in the argument list itself which I'm nor aware of ? in your case public int getD(return d);

ok mistakes apart.... this can be used for calling methods,constructor or to refer members of own class..... while super can be used for calling methods,constructor or to refer members of parent class of course if they are visible to child class.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9302
    
  17

Folkert, can you indent your code please.


Which code do you think looks better and is more readable. If a person is not able to read your code, how is him/her supposed to help you??


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: return super.getC(); equals to return this.getC();