Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| |||||||||||
Core Java - Interview Questions and Answers for 'Super' - 5 question(s) found - Order By Rating | |||||||||||
| |||||||||||
Ans. Used to access members of the base class. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   oops   java keywords   super   basic interview question Asked in 2 Companies basic   frequent | |||||||||||
| |||||||||||
Ans. No, because both this and super should be the first statement. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   oops  this   super   constructor Asked in 1 Companies intermediate   rare | |||||||||||
Try 2 Question(s) Test | |||||||||||
| |||||||||||
Ans. 1.this is a reference to the current object in which this keyword is used whereas super is a reference used to access members specific to the parent Class. 2.this is primarily used for accessing member variables if local variables have same name, for constructor chaining and for passing itself to some method whereas super is primarily used to initialize base class members within derived class constructor. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   oops   class   objects   inheritence   constructor   this   super   this vs super Asked in 1 Companies | |||||||||||
Try 1 Question(s) Test | |||||||||||
| |||||||||||
Ans. Java expects the superclass ( Object Class ) constructor to be called while creation of any object. So super constructor is called in case there are no instance variables to initialize. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   constructor   object creation   default constructor   super | |||||||||||
Try 1 Question(s) Test | |||||||||||
| |||||||||||
Ans. Derived object carries the body of its class as well as the body of the parent class. Its body ( member elements ) is initialized using its own class constructor whereas the body ( member elements ) carried from the parent class are initialized using super class constructor. So In order to initialize the elements of the parent class before its own elements are even initialized, super is called. | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  java   oops   constructor   super   inheritance  object oriented programming (oops)  oops concepts   inheritence Asked in 1 Companies intermediate | |||||||||||
| |||||||||||
| |||||||||||