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


Share

Search Java Test Questions


 223 test questions in repository.




Java - Test Questions on 'overriding' - 9 questions found


Overridden methods must have the same ... Core Java
name
name and argument list
name, argument list, and return type
name, argument list, return type and belong to the same class

  java  overriding

Which of the following can be overridden ?Core Java
final instance methods
final static methods
non final instance methods
non final static methods

  overriding

What will be the ouput upon executing main method ?

public class Vehicle {
   public void move(){
      System.out.println("Vehicle is moving");
   }
}

public class Car {
   public void move(){
      super().move();
      System.out.println("Car is moving");
   }

   public static void main(String[] args){
      new Car().move();
   }
}
Core Java
Vehicle is moving
Car is moving
Vehicle is moving Car is moving
Compilation Error

  overriding

What will be the output upon exceuting main method ?

public class Vehicle {
   private void move(){
      System.out.println("Vehicle is moving");
   }
}

public class Car extends Vehicle{
   public void move(){
      System.out.println("Car is moving");
   }

   public static void main(String[] args){
      Vehicle vehicle = new Car();
      vehicle.move();
   }
}
Core Java
Vehicle is moving
Car is moving
Vehicle is moving Car is moving
Compilation error

  overriding

What will be the output upon executing the main method ?

public class Vehicle {
   public void move(){
      System.out.println("Vehicle is moving");
   }
}

public class Car extends Vehicle{
   public void move(){
      System.out.println("Car is moving");
   }

   public static void main(String[] args){
      Vehicle vehicle = new Vehicle();
      ((Car)vehicle).move();
   }
}
Core Java
Vehicle is moving
Car is moving
Cimpilation Error
Runtime Exception

  overriding

Overriding is not possible without ..Core Java
Inheritance
Composition
Inner Classes
Abstract Classes

  overriding

Which of the following can be marked static ?Core Java
Methods , Variables and Initialization Blocks.
Methods , Variables , Initialization Blocks and Outer Classes and nested Classes.
Methods , Variables , Initialization Blocks and Outer Classes.
Methods , Variables , Initialization Blocks and nested Classes.

  oops  java  static  nested classes  static nested classes

Which of the following cannot be marked static ?Core Java
Constructors , Classes ( Outer ) , Classes ( nested ), Interfaces , Local variables , Inner Class methods and instance variables.
Constructors , Classes ( Outer ) , Interfaces , Local variables , Class variables , Class Methods , Inner Class methods and instance variables.
Constructors , Classes ( Outer ) , Interfaces , Local variables , Inner Class methods and instance variables.
Constructors , Classes ( Outer ) , Classes (Nested), Interfaces , Local variables , Inner Class methods and instance variables.

  oops  java  static  nested classes  static nested classes

Which of the following is false for final ?Core Java
Final methods cannot be overriden
Final methods cannot be overloaded
Final classes cannot be subclassed
Final class cannot be abstract

  java  final  java keyword







comments powered by Disqus