Java - Online Test - Super - javasearch.buggybread.com


Share

Search Java Test Questions


 223 test questions in repository.




Java - Test Questions on 'super' - 3 questions found


What is the problem with this code ?

public class Car extends Vehicle{   
   int x;
   
   Car(int y){
      x = 5;
   }
   
   Car(){
      this(5);
      super();
   }
}
Core Java
We cannot overload constructors
Constructors should have type
we should have called super() before this(5)
We cannot have both super() and this() in a constructor

  Constructor  this  super

What is the problem with this code ?

public class Car extends Vehicle{
   int x;

   Car(int y){
      x = 5;
   }

   Car(){
      super();
      this.x = 5;
   }
}
Core Java
We cannot overload constructors
We cannot call super in overloaded constructor
we cannot have this and super in constructor
There is no problem

  constructor  this  super

What is a default constructor ?Core Java
Constructor without parameters declared by user
Constructor provided by Java if no constructor is declared
Constructor with empty body
All of the above

  Constructor







comments powered by Disqus