TOTAL QS = 10Time [ 00 : 00 : 00 ]
00:00:00

Java Method Overloading Basics Online Test 1

Instructions

Total Questions: 10

Total Minutes: 10

This ExamTray Free Online Test or Quiz or Trivia tests your Programming Skills on basics of Java Method Overloading. This test displays answers after finishing the exam for review. You can easily clear Competitive Exams and Job Interview Questions. Students can learn Java basics.

Go through Java Theory Notes on Method Overloading before attempting this test.

All the Best

Challenge SCORE

0 / 10

Take This Exam
1) To successfully overload a method in Java, the return types must be ___.
2) To successfully overload a method in Java, the argument-list or parameter-list must be ___.
3) What is the output of the below Java program with multiple methods?
public class MethodOverloading1
{
  void show(int a, char b)
  {
    System.out.println("KING KONG");
  }

  void show(char a, int b)
  {
    System.out.println("JIM JAM");
  }
	
  public static void main(String[] args)
  {
    MethodOverloading1 m = new MethodOverloading1();
    m.show(10, 'A');
    m.show('B', 10);
  }
}
4) To successfully overload a method in Java, the method names must be ___.
5) What is the output of the below Java program?
public class MethodOverloading2
{
  int info()
  {
    System.out.println("PLANE");
    return 0;
  }

  void info()
  {
    System.out.println("AIRPORT");
  }

  public static void main(String[] args)
  {
    MethodOverloading2 m = new MethodOverloading2();
    int a = m.info();
  }
}

6) What is the output of the below Java program with method overloading?
class Wood{ }
class SubWood extends Wood{ }

public class MethodOverloading3
{
  Wood display(int a)
  {
    System.out.println("PINE");
    return new Wood();
  }
  SubWood display()
  {
    System.out.println("TEAK");
    return new SubWood();
  }

  public static void main(String[] args)
  {
    MethodOverloading3 m = new MethodOverloading3();
    m.display();
  }
}
7) What is the output of the below Java program trying to overload a method "jump"?
class Rabbit{ }
class WildRabbit extends Rabbit{ }

public class MethodOverloading4
{
  Rabbit jump()
  {
    System.out.println("Rabbit Jump");
    return new Rabbit();
  }
  WildRabbit jump()
  {
    System.out.println("Wild Rabbit Jump");
    return new WildRabbit();
  }

  public static void main(String[] args)
  {
    MethodOverloading4 obj = new MethodOverloading4();
    obj.jump();
  }
}
8) Java method overloading implements the OOPS concept ___.
9) Which is the overloaded static method of Math class to get absolute value in Java?
10) What is the output of the below Java program that tries to overload a method "abs"?
public class MyAbs
{
  static int abs(int a)
  {
    return a<0?-a:a;
  }
  static float abs(float b)
  {
    return b<0?-b:b;
  }
  static double abs(double c)
  {
    return c<0?-c:c;
  }
  public static void main(String[] args)
  {
    int a=-10;
    float b=-4.56f;
    double c=-10.123;
    System.out.println(MyAbs.abs(a) + ", " + MyAbs.abs(b) + ", " + MyAbs.abs(c));
  }
}

Open Certification Helper Popup Reset Popup