What is "super" used for ?
Javasearch.buggybread.com

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.
Label / Company      Label / Company / Text

   



Interview Questions and Answers

 Q1. What is "super" used for ?
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


Related Questions

  Can we use both "this()" and "super()" in a constructor ?
  Why every object constructor automatically call super() in Object before its own constructors?
  Difference Between this() and super() ?
  Which of the following is false about Constructors ?
  Does a class inherit the constructor of its super class?
  In a case where there are no instance variables what does the default constructor initialize?
 What will the following code print upon executing main method of Main class ?

public class BaseClass {
BaseClass(){
System.out.println("Hello I am in Base Class Constructor");
}
}

public class DerivedClass extends BaseClass{
DerivedClass(){
System.out.println("Hello I am in Derived Class Constructor");

super();
}
}

public class Main {

public static void main(String[] args) {
    DerivedClass derivedClass = new DerivedClass();
}
}

 What will the following code print upon executing main method of Main class ?

public class BaseClass {
BaseClass(int x){
System.out.println("Hello I am in Base Class Constructor");
}
}

public class DerivedClass extends BaseClass{
DerivedClass(){
super(1);
System.out.println("Hello I am in Derived Class Constructor");
}
}

public class Main {

public static void main(String[] args) {
    DerivedClass derivedClass = new DerivedClass();
}
}
 What will the following code print upon executing main method of Main class

public class BaseClass {

BaseClass(){
this(2);
System.out.println("Hello I am in Base Class Constructor");
}

BaseClass(int i){
System.out.println("Hello I am in Base Class int argument Constructor");
}
}

public class DerivedClass extends BaseClass{
DerivedClass(){
super(1);
System.out.println("Hello I am in Derived Class Constructor");
}
}

public class Main {

public static void main(String[] args) {
DerivedClass derivedClass = new DerivedClass();
}
}



Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: